Click here to Skip to main content
14,696,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change a particular row color of gridview based on some condition, i am using ASP.NET with c#.

Thanks in advance
Posted

1 solution

Make use of GridView.RowDataBound Event[^]
void YourGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  {
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // Check whatever condition you want
      e.Row.BackColor =  Drawing.Color.Red;//And change the color
    }
  }

Regards..
   
Comments
Norris Chappell 24-May-15 16:56pm
   
I did exactly like you indicated but it is highlighting the last field. If it was highlighting the whole row that would be okay too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900