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

Binding to a checkbox within a Grid

2 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 18 Nov 2008, 03:23 PM
Hi,
How do I bind a dataTable to a Grid when the Grid row contains an asp:checkbox control within GridTemplateColumn? The initial state of the checkbox "Enabled" is set from the dataTable. 

How do I maintain the state of these checkboxes during postbacks?

<

 

Columns>

 

 

 

 

<telerik:GridTemplateColumn UniqueName="TemplateColumn" >

 

 

 

 

<ItemTemplate>

 

 

 

 

<asp:Panel ID="Panel1" runat="server">

 

 

 

 

<asp:CheckBox ID="Enabled" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" />

 

 

 

 

</asp:Panel>

 

 

 

 

</ItemTemplate>

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

<

 

telerik:GridDropDownColumn UniqueName="System" ListTextField="rSystemName" ListValueField="System" ListDataMember="rSystems" DataField="System" HeaderText="r system"  DropDownControlType="RadComboBox" />

 

 

 

 

<telerik:GridBoundColumn UniqueName="Value" DataField="Value" HeaderText="Value"  />

 

 

 

 

<telerik:GridTemplateColumn UniqueName="TemplateColumn" >

 

 

 

 

<ItemTemplate>

 

 

 

 

<asp:Panel ID="Panel5" runat="server">

 

 

 

 

<asp:CheckBox ID="Switch" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" />

 

 

 

 

</asp:Panel>

 

 

 

 

</ItemTemplate>

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridBoundColumn UniqueName="Alpha" DataField="Alpha" HeaderText="α"  />

 

 

 

 

<telerik:GridBoundColumn UniqueName="Beta" DataField="Beta" HeaderText="β" HeaderStyle-HorizontalAlign="Center" />

 

 

 

 

</Columns>

 

 

 

<

 

EditFormSettings CaptionFormatString="Edit details for route with Id {0}" CaptionDataField="Id">

 

 

 

 

<FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle>

 

 

 

 

<FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle>

 

 

 

 

<FormStyle Width="100%" BackColor="#eef2ea"></FormStyle>

 

 

 

 

<EditColumn ButtonType="ImageButton" />

 

 

 

 

</EditFormSettings>

 

 

 

 

</MasterTableView>

 

 

 


The dataTable comes from a dataSet

protected

 

void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

 

{

 

 

 

if (Session["Routes"] == null)

 

{

RadGrid1.DataSource = Routes;

 

 

 

}

 

 

 

 

else

 

 

 

{

RadGrid1.DataSource = Session[

"Routes"];

 

 

 

 

}

 

}

 

 



Any help much appreciated?
 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2008, 04:48 AM
Hi Steve,

Go through the following help article which explains how to maintain checkbox control state in a GridTemplateColumn.
Persisting CheckBox control state in GridTemplateColumn on rebind

Shinu.
0
Steve
Top achievements
Rank 1
answered on 19 Nov 2008, 11:02 AM
Hi,
Any suggestions for the checkbox binding problem?

Thanks
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steve
Top achievements
Rank 1
Share this question
or