Select all only selects items on first page

4 posts, 0 answers
  1. Matthew
    Matthew avatar
    25 posts
    Member since:
    Aug 2011

    Posted 09 Mar 2012 Link to this post

    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;
    }

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 09 Mar 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matthew
    Matthew avatar
    25 posts
    Member since:
    Aug 2011

    Posted 09 Mar 2012 Link to this post

    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.
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 10 Mar 2012 Link to this post

    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
Back to Top