On of the useful things you can do with GridViews in ASP.NET is to run code during the rendering of each individual row. This allows you to change aspects, such as visual appearance, of each row based on the values of the cells. For instance, you can change the background color of the cell based on the value:

To accomplish this, you simply need to add a function to the “RowDataBound” attribute of the GridView.

In this example, I took the value of the 3rd cell of the row (“e.Row.Cells[2]”) and changed the background color of the cell based on the value.

Pin It on Pinterest

Share This
%d bloggers like this: