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

Popular posts from this blog

C# Crop white space from around the image

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

The specified version string contains wildcards, which are not compatible with determinism.