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

[Solved] Select all record with check box

5 Answers 215 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 14 Apr 2009, 07:52 AM
Hi team:
  I have a  grid and with check box every row,now I checked the column checkbox it only select from the current page that is the 1st page,If there are more then one page the user has to go to each page and do select all. Can you give a  demo ,thanks !

tommy.


5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 14 Apr 2009, 12:04 PM
Hi Tommy,

When the grid is in paging mode only the items for the current page are retrieved - there are no items in memory.
Additionally If you want to operate with all records from the source when the grid paging is enabled, reference directly the data from the underlying data source to process further operations over it.

The other solution is to disable temporary the paging feature of the control.
You have to set the AllowPaging property of the grid to false at a certain stage of the lifecycle and rebind the control invoking its Rebind() method, then traverse all items in it. When you are done with this task, set the AllowPaging property back to true and rebind the grid to enable the paging feature again.

Additionally, in order to persist the selection across different grid pages, consider the solution presented in this section of the online documentation:
http://www.telerik.com/help/aspnet-ajax/grdpersistselectedrowsonsorting.html

Regards,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Tommy
Top achievements
Rank 1
answered on 15 Apr 2009, 02:09 AM
thanks for your answer
0
Tommy
Top achievements
Rank 1
answered on 15 Apr 2009, 03:26 AM
By the way
  How to get the check box control in the column.After change the page index , the column check box status will be change from checked to uncheck ,I try to use findcontrol function,but is failed. Following is my code.

  Asp Code
<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
      <HeaderTemplate>
         <asp:CheckBox ID="headerChkbox" OnCheckedChanged="DistToggleSelectedState" AutoPostBack="True" runat="server">       </asp:CheckBox>
     </HeaderTemplate>
     <ItemTemplate>
             <asp:CheckBox ID="CheckBox1" OnCheckedChanged="DistToggleRowSelection" AutoPostBack="True"runat="server"></asp:CheckBox>
     </ItemTemplate>
</telerik:GridTemplateColumn>

C# code
              
System.Web.UI.WebControls.CheckBox cb1 =RadGrid.HeaderContextMenu.FindControl("headerChkbox"as System.Web.UI.WebControls.CheckBox;System.Web.UI.WebControls.CheckBox cb2 =RadGrid.FindControl("headerChkbox"as System.Web.UI.WebControls.CheckBox;

"cb1" and "cb2" are both nullable value.
Can you give me a hand to deal with this problem.
Thanks very much again!

Tommy




0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Apr 2009, 07:46 AM
Hello Tommy,

You can access the checkbox in the HeaderTemplate of the TemplateColumn as shown below:
c#:
protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            CheckBox checkbox = (CheckBox)header.FindControl("headerChkbox"); 
             
        } 
     } 

Thanks
Princy.
0
Tommy
Top achievements
Rank 1
answered on 15 Apr 2009, 09:35 AM
Thanks again for the professional answer.
Tags
Grid
Asked by
Tommy
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Tommy
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or