I have a GridView which is bound automaticaly to a SqlDataSource. I have a function which goes thru the GridView and colors red certain cells according to their content. I also enabled sorting on the GridView on all columns. When the page first loads the function coloring appropriate cells works. When I click the column header to sort, it sorts, but the cells that should be colored doen’t get colored. I tried putting the call to the coloring function in the Page_Load in an if(isPostBack) condition and I tried using the GridView_Sorted event putting the call to the coloring function in there. None of that worked. I also tried adding GridView1.DataBind() in both the Page_Load and GridView_Sorted events before calling the coloring function and after. In all scenarios sorting worked but coloring did not!
How can I get both sorting and coloring working?
Thank you.
I have a GridView which is bound automaticaly to a SqlDataSource. I have a
Share
To enable accepting the answer, i copy my comment here:
Put your coloring logic into GridView’s RowDataBound event.