Changing the color of a row in a GridView in ASP.NET
Change the color of a row depending on whether the Doctor is Active or Inactive
protected void grdview_RowDataBound(object sender, GridViewRowEventArgs e)
{
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((string.IsNullOrEmpty(e.Row.Cells[3].Text) != true) ||
(e.Row.Cells[3].Text != " "))
{
Char result = Convert.ToInt32(e.Row.Cells[3].Text);
if (result == ‘Y’) e.Row.BackColor = System.Drawing.Color.Aqua;
else if (result ==’N’) e.Row.BackColor = System.Drawing.Color.Cornsilk;
}
}
}
}
Change the Color of the cells depending on the Value of a column
protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((string.IsNullOrEmpty(e.Row.Cells[3].Text) != true)
|| (e.Row.Cells[3].Text != " "))
{
string result = Convert.ToInt32(e.Row.Cells[2].Text);
if (result == “M.S”)
e.Row.Cells[3].BackColor= System.Drawing.Color. Aquamarine;
else
e.Row.Cells[3].BackColor= System.Drawing.Color. BlanchedAlmond;
}
}
}
}
Comments
Post a Comment