I have an unbound checkbox column that the user checks to select rows. How can I count up the number of rows clien-side the user has checked?
That sounds exactly like what I'm looking for! Thanks!
Can you point me in the direction for the documentation on how to use JavaScript with an ASP.NET Webforms application? I'm not sure where I need to put this code to make it work.
Thanks,
Chris
Hello Crendal,
Thank you for posting in our community.
From your post I assume that you have already implemented the logic for selecting/unselect rows on check/uncheck of the UnboundCheckBox column in the grid and what you are looking for is how to get the number or currently selected rows on the client side. If this is the case, what I can suggest is using get_selectedRows method of WebDataGrid. This method gets a reference to the currently selected rows collection. Afterwards, in order to get the count of the items in this collection the get_length method could be used. For example:
var grid = $find("WebDataGrid1"); var selectedRowsCount = grid.get_behaviors().get_selection().get_selectedRows().get_length();
var grid = $find("WebDataGrid1");
var selectedRowsCount = grid.get_behaviors().get_selection().get_selectedRows().get_length();
If I this is not an accurate demonstration of what you are trying to achieve please feel free to send me a small isolated sample where I could get a better idea of your scenario along with any clarifications if you consider them needed.
I hope you find this information helpful.
Please feel free to contact me if you have any additional questions regarding this matter.