I want to change the colour of row in grid view if a condition is met.
For example if the column Completed has the value = "yes"
I want the colour to be yellow.
othersise it could be white.
I need help regarding his.
Any help will be appreciated.
Regards
Loading
Pelumi EluyeraPosted Apr 29, 2015, 7:54 AM
I have tried the code youve given me exactly.
however i get an error.
Please see the attached picture.
Any help will be appreciated.
Rajkiran SwainPosted Apr 29, 2015, 7:34 AM
Rajkiran SwainPosted Apr 29, 2015, 7:33 AM
Manoj Kumar MandalPosted Apr 29, 2015, 7:12 AM
Check this link http://stackoverflow.com/questions/5048762/change-gridview-row-color-based-on-condition-in-c-sharp
Siva SankarPosted Apr 29, 2015, 7:10 AM
Please write the code as below...
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
//If Salary is less than 10000 than set the row Background Color to Cyan
if(Convert.ToInt32(e.Row.Cells[3].Text)<10000)
{
e.Row.BackColor = Color.Your_Color;
}
}
}