How to set different color for each Group Header in WebGrid
Hi All,
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:
1 2 3 4 5 6 7 8 9 10 |
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; else 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.
Cheers,
Gordon Tumewu
Excellent site intersoftpt.wordpress.com and I am really pleased to see you have what I am actually looking for here: this .. as it’s taken me literally 2 hours and 50 minutes of searching the web to find you (just kidding!) so I shall be pleased to become a regular visitor
Thanks for the compliment :), actually this is our blog, our company website is http://www.intersoftpt.com, you can download the trial version and check about our products. If you have difficulity just send email to technical@intersoftpt.com and our support team will provide you with the solution.