[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ON ROW DATA BOUND ISSUE

Posted on 2011-09-22
7
Medium Priority
?
208 Views
Last Modified: 2012-05-12
I have the attached gridview which I want to change the row color when a certain condition exists in column "Status1" = "AOG".   The onrowdatabound event does not seem to be firing.  Any assistance with the code would be appreciated.
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" onrowdatabound="GridView1_RowDataBound" DataKeyNames="ID" AllowSorting="True" Font-Size="Small" Font-Names="Arial" ShowFooter="True" HorizontalAlign="Center">
<RowStyle HorizontalAlign="Center" BackColor="White" ForeColor="Black" Width="1300px" />

<Columns>

Open in new window

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Home1All : System.Web.UI.Page
{
    protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Status1")) == "AOG")
            {
                e.Row.BackColor = System.Drawing.Color.Red;
            }
            else
            {
                e.Row.ForeColor = System.Drawing.Color.Yellow;

            }
        }
    }
}

Open in new window

0
Comment
Question by:BOEING39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 36584878
try calling the gridview.databind() method and hopefully then your events might fire
http://forums.asp.net/t/1048369.aspx/1
0
 

Author Comment

by:BOEING39
ID: 36584978
No help......
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36585188
Hi,
When are you calling your gridview.databind() method?
If you are calling on Page_Load(), Call it in !IsPostBack i.e.

Page_Load()
{
                    if(!IsPostBack)
                     {
                                //Here you gridview bindung code comes.
                      }
}

Regards,
Ram
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:BOEING39
ID: 36587669
Can you assist in the placement of the page Load Event and data bind method code placement.   I an very new to this.....  

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Home1All : System.Web.UI.Page
{
    protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Status1")) == "AOG")
            {
                e.Row.BackColor = System.Drawing.Color.Red;
            }
            else
            {
                e.Row.ForeColor = System.Drawing.Color.Yellow;

            }
        }
    }
}

Open in new window

0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 2000 total points
ID: 36591934

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Home1All : System.Web.UI.Page
{

     protected void Page_Load(object sender, EventArgs e)
     {
              if(!IsPostBack)
                     {
                           GridView1.DataSource= GetdataSource();//GetDataSource is the Method which returns datsource for your griedview
                           GridView1.DataBind():
                      }
     }
    protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Status1")) == "AOG")
            {
                e.Row.BackColor = System.Drawing.Color.Red;
            }
            else
            {
                e.Row.ForeColor = System.Drawing.Color.Yellow;

            }
        }
    }
}

Open in new window

0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36591940
Hope this will help you.

Regards,
Ram
0
 

Author Closing Comment

by:BOEING39
ID: 36593584
That did it.  Thx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question