This is a migrated thread and some comments may be shown as answers.

Radgrid Selected Items resets to 0

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 19 Sep 2011, 08:28 PM
Hello,
    I have a RadGrid with a check box column to select the row and I have used the code in this demo http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx
    For some reason after selecting 4th row the RadGrid.SelectedItems resets to 0.I am populating a listbox based on the selected items in the radgrid but this does not work because of the above mentioned issue. I have noticed while debugging that the non public member "Capacity" is by default set to 4, not sure how to set/override it.
    For now I had to get around the problem by iterating to all the items in the Radgrid ,then use the FindControl to get the checkbox checked status and then populate the Listbox.This works so far but I feel its a workaround.
Not sure what I am missing.Any help is much appreciated.

Old code

 

((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked; 
 foreach (GridDataItem row in RadGrid1.SelectedItems) 
      RadlstOLDest.Items.Add(new RadListBoxItem(row["OrderLineId"].Text, row["OrderLineId"].Text)); 

 
New Code

foreach (GridDataItem row in RadGrid1.MasterTableView.Items) 
{
    if ((row.FindControl("CheckBox1") as CheckBox).Checked) 
    {
                RadlstOLDest.Items.Add(new RadListBoxItem(row["OrderLineId"].Text, row["OrderLineId"].Text)); 
                row.Selected = true
    }
}

Thanks,
Vikas

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 22 Sep 2011, 12:10 PM
Hello Vikas,

I have tested the Server-Side Row Selection demo of the RadGrid and there is no problem with selecting more than 4 rows.
To get the selected items of the RadGrid, you can use the SelectedItems Property.

I hope this helps.

All the best,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Vikas
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or