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

Select all only selects items on first page

3 Answers 184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 09 Mar 2012, 05:40 PM
Within a RadGrid that uses the NeedDataSource method and using paging, there is a select all column. When the Header checkbox is selected, the items on the first page are selected only. How can I select all of the records within the RadGrid.

This is the code I have in place for selecting all dataitems:
CheckBox headerCheckBox = (sender as CheckBox);
foreach (GridDataItem dataItem in this.radgridmailinglists.MasterTableView.Items)
{
    (dataItem.FindControl("chxselectrow") as CheckBox).Checked = headerCheckBox.Checked;
    dataItem.Selected = headerCheckBox.Checked;
}

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Mar 2012, 06:49 PM
Hello,

CheckBox headerCheckBox = (sender as CheckBox);
            RadGrid1.AllowPaging = false;
            RadGrid1.Rebind();
            foreach (GridDataItem dataItem in this.RadGrid1.Items)
            {
                (dataItem.FindControl("chxselectrow") as CheckBox).Checked = headerCheckBox.Checked;
                dataItem.Selected = headerCheckBox.Checked;
            }


Thanks,
Jayesh Goyani
0
Matthew
Top achievements
Rank 1
answered on 09 Mar 2012, 08:26 PM
I tried that example however, the visual aspect of the grid changes to no paging, which I want to keep the paging after the checkboxes are selected.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Mar 2012, 03:17 PM
Hello,

CheckBox headerCheckBox = (sender as CheckBox);
            RadGrid1.AllowPaging = false;
            RadGrid1.Rebind();
            foreach (GridDataItem dataItem in this.RadGrid1.Items)
            {
                
                    // access here
            }
RadGrid1.AllowPaging = true;
            RadGrid1.Rebind();


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Matthew
Top achievements
Rank 1
Share this question
or