How to set different color for each Group Header in WebGrid
Few weeks ago I got interesting inquiry from one of our customers, about how to set different color for each group header in WebGrid, and I think that it’s an interesting topics to be post on our corporate blogs.
Ok, first of all you need to bind your Webgrid and at the code behind inside WebGrid1_InitializeRow event, you can add the following code:
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
if (e.Row.Type == ISNet.WebUI.WebGrid.RowType.GroupHeader)
if (e.Row.Cells.GetNamedItem("<em>your column name</em>").Text == "<em>the content of your cell</em>")
e.Row.Style.BackColor = Color.Red;
e.Row.Style.BackColor = Color.Yellow;
For more information, you can download the sample here. The sample used Northwind.mdb and the WebGrid bind to AccessDataSource.
If you have questions regarding this solution, please don’t hesitate to post the question in here.