I have a grid that when put in edit mode has a popup editform that has another grid containing records with checkboxes in the grid column edit template. I want to add a checkbox in the header that when selected will toggle the checkboxes in all the rows to checked or unchecked. Here is the column definition in my editforms child grid:
I am getting a null value when trying to access the items in the ToggleSelectedState method for the grid items. Here is my code-behind in c#:
grdClaimHist is the parent grid that contains the editform while grdClaimDetail is the child grid. Is there another way I should be trying to implement this functionality since the ToggleSelectedState method is called on my header checkbox click?
<
telerik:GridTemplateColumn
UniqueName
=
"Resubmitted"
DataField
=
"Resubmitted"
HeaderStyle-HorizontalAlign
=
"Left"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"20%"
>
<
HeaderTemplate
>
<
asp:CheckBox
id
=
"headerChkbox"
OnCheckedChanged
=
"ToggleSelectedState"
AutoPostBack
=
"true"
runat
=
"server"
Text
=
" resubmitted"
></
asp:CheckBox
>
</
HeaderTemplate
>
<
EditItemTemplate
>
<
asp:CheckBox
id
=
"chkResubmittedEdit"
runat
=
"server"
Checked='<%# Bind("Resubmitted") %>'/>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
id
=
"chkResubmittedItem"
runat
=
"server"
Checked='<%# Eval("Resubmitted") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
I am getting a null value when trying to access the items in the ToggleSelectedState method for the grid items. Here is my code-behind in c#:
protected void ToggleSelectedState(object sender, EventArgs e)
{
CheckBox headerCheckBox = (sender as CheckBox);
try
{
GridDataItemCollection items = (grdClaimHist.FindControl("grdClaimDetail") as RadGrid).MasterTableView.Items;
foreach (GridDataItem dataItem in items)
{
CheckBox chk = (dataItem.FindControl("chkResubmittedEdit") as CheckBox);
chk.Checked = headerCheckBox.Checked;
}
}
catch (Exception ex)
{
//continue
}
}