Hello Everyone,
I am working on a custom user control which has a GridView on it. I have a checkbox column and have the EnableHeaderCheckBox property set to TRUE. The grid works great; I can click on the Header Checkbox and toggle all checkboxes, etc. However, I am trying to create a method to allow the consumers of this user control to programmatically Select All or Unselect All (basically, mimicking the functionality of the Header Checkbox).
I have tried these but they did not work:
1)
grid.SelectAll();
grid.ClearSelection();
2)
foreach
(var row
in
grid.Rows)
row.IsSelected =
true
;
Only this one works, but it takes a little bit of time to select/unselect all rows:
foreach
(var row
in
grid.Rows)
row.Cells[
"Select"
].Value =
true
;
//or false to unselect
When I click on the Header Checkbox, rows are selected/unselected immediately, which is what I am looking for. I also need to make sure that the grid_CellValueChanged event is fired.
Any help is greatly appreciated.
Thanks!