I have a dynamically loaded grid (automatic column generation, data table as a source) and currently I use the code below to catch the rows as they are created and compare their content to the previous row to track changes in the data. If nothing changed i want to hide the row from the grid. Based on everything i have read the code below should work properly and it does for highlighting column changes BUT for some reason its ignoring the e.Item.Visible setting and still showing rows that I have set to hidden. Thanks in advance!
01.System.Data.DataTable dt = null;02.int rowCnt = 0;03.List<int> colsNotToTrack = new List<int>();04.protected void rgResults_ItemCreated(object sender, GridItemEventArgs e)05.{06. if (compareLines && e.Item is GridDataItem)07. {08. if (rowCnt > 0)09. {10. bool changed = false;11. for (int i = 2; i < e.Item.Cells.Count; i++)12. {13. if (colsNotToTrack.Contains(i))14. continue;15. if (dt.Rows[rowCnt][i - 2].ToString() != dt.Rows[rowCnt - 1][i - 2].ToString())16. {17. e.Item.Cells[i].BackColor = System.Drawing.Color.LightSalmon;18. changed = true;19. }20. }21. e.Item.Visible = changed;22. }23. rowCnt++;24. }25. 26.}