I have a RadGrid that is bound to a SQL database. On the select statement I generate a column that is not in the table. "SELECT '-' as [CheckBox] ...". I then use the ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) event on the RadGrid to add a column of check boxes (one on each row). The user selects certain check boxes (specifying a row) and presses a submit button. How can I read what rows were selected?
I do not use the information to update the database. The database is used for management and does not change. If I can't read the selection is there a different way to do this? Using a RadGrid is just so nice so I would like to keep using that, but I don't need to bind it to a database.
5 Answers, 1 is accepted
It seems like there is a much easier way to do this. I followed the example at the end of this thread, but the button click event does not indicate that anything was selected. I am on an old version and the post was about a change from v2009 to v2012. Could my problem be a version problem?
Please examine the following article that describe in detail how you can implement server-side selection for items in RadGrid via CheckBox.
Thank you for that reference. I have looked at it, but I can't see how to read all the selected items on a submit button click. The example and what it referenced did not seem to do that.
I have tried the code below, but it fails on "CheckBox chk = (CheckBox)item["CheckBox1"].Controls;". If I try "(dataItem.FindControl("CheckBox1") as CheckBox).Checked" that seems to select everything. The goal is to be able to identify which rows were selected and give me the value of one item in that row.
The fix was too easy. Just use item.selected.
I am glad that you have the functionality working.
Thank you for sharing your approach with the community. This can be helpful for someone that is trying to implement similar functionality.