I have a RadGrid with a custom CommandItemTemplate which contains a checkbox within it. The data which is displayed in the grid is dependent on whether the checkbox is checked or not, which means that in the onCheckChanged handler for the checkbox, I must call the grid.Rebind() method. The problem however is that whenever I call the rebind method, the checkbox resets its state back to unchecked.
Here is the ASPX code:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
Skin="Vista" Width="287px">
<mastertableview autogeneratecolumns="False" commanditemdisplay="Top">
<Columns>
<telerik:GridBoundColumn DataField="ID" EmptyDataText="&nbsp;" HeaderText="ID" UniqueName="ID"></telerik:GridBoundColumn>
</Columns>
<CommandItemTemplate>
<asp:CheckBox id="chkShowExistingMappings" runat="server" Text="Show nodes with existing mappings" AutoPostBack="True" Width="237px" __designer:wfdid="w26" OnCheckedChanged="chkShowExistingMappings_CheckedChanged"></asp:CheckBox>
</CommandItemTemplate>
</mastertableview>
</telerik:RadGrid>
And here is the code behind:
protected DataTable GetData()
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Product", typeof(string));
table.Columns.Add("MinPrice", typeof(double));
table.Columns.Add("Price", typeof(double));
table.Rows.Add(1, "Tea", 1.00, 1.32);
table.Rows.Add(2, "Chocolate", 4.00, 4.70);
table.Rows.Add(3, "Cookies", 2.50, 3.06);
return table;
}
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetData();
}
protected void chkShowExistingMappings_CheckedChanged(object sender, EventArgs e)
{
RadGrid1.Rebind();
}
If you run it and tick the checkbox, you will see that it doesnt maintain its checked state. Can anyone tell me how to get this working please?
Thanks
Here is the ASPX code:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
Skin="Vista" Width="287px">
<mastertableview autogeneratecolumns="False" commanditemdisplay="Top">
<Columns>
<telerik:GridBoundColumn DataField="ID" EmptyDataText="&nbsp;" HeaderText="ID" UniqueName="ID"></telerik:GridBoundColumn>
</Columns>
<CommandItemTemplate>
<asp:CheckBox id="chkShowExistingMappings" runat="server" Text="Show nodes with existing mappings" AutoPostBack="True" Width="237px" __designer:wfdid="w26" OnCheckedChanged="chkShowExistingMappings_CheckedChanged"></asp:CheckBox>
</CommandItemTemplate>
</mastertableview>
</telerik:RadGrid>
And here is the code behind:
protected DataTable GetData()
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Product", typeof(string));
table.Columns.Add("MinPrice", typeof(double));
table.Columns.Add("Price", typeof(double));
table.Rows.Add(1, "Tea", 1.00, 1.32);
table.Rows.Add(2, "Chocolate", 4.00, 4.70);
table.Rows.Add(3, "Cookies", 2.50, 3.06);
return table;
}
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetData();
}
protected void chkShowExistingMappings_CheckedChanged(object sender, EventArgs e)
{
RadGrid1.Rebind();
}
If you run it and tick the checkbox, you will see that it doesnt maintain its checked state. Can anyone tell me how to get this working please?
Thanks