Author: ekberglinda | Posted on: 2/11/2009 9:41:52 AM | Views : 309

Hi!

My GridView (ASP.NET Visual Studio 2005) has both DataBound and non-DataBound fields.
I want to change the BackColor of each row to something unique and do this in the RowDataBound event.
It works perfectly if I remove all TemplateFields from the GridView, otherwise nothing happens.
I don't get an error, it simply does not change the BackColor of the rows.

My code:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
   string color = "";
  
   if (e.Row.RowType == DataControlRowType.DataRow)
   { 
      color = e.Row.Cells[6].Text.ToString();

      e.Row.BackColor ...

Go to the complete details ...