I am using RadGrid with Checkbox that i use to allow the user to select multi rows by checking the check box.
What i am facing is when i check the checkbox in the grid from top of the grid going down it works fine with me, i can later read all the selected rows nicely. But if i check the checkbox randomly top then button and then to, the reading will be incorrect. that means i can not get the selected rows correctly. So if i select 3 rows from button to up direction and try to read the selected rows, it return the
button row 3 times instead the value of the 3 row.
I hope i am making sense ....
I am using the following code.
Note Multi selection Server Side.
To Read the selected rows:
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
If CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = True Then
ListBox1.Items.Add(CType(RadGrid1.SelectedItems(0), GridDataItem)("ID").Text)
dataItem.Selected =
False
End If
Next
For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = False
Next
End Sub
Protected
Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender
For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
If CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = True Then
dataItem.Selected = True
End If
Next
End Sub
Hope some one will direct me to the right way of doing it.
Many Thanks
Omar