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

Checkbox CheckedChanged event in GridTemplateColumn

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ilija
Top achievements
Rank 1
Ilija asked on 24 Jul 2008, 07:48 PM
Hi Guys,

I am having a hard time putting an asp:CheckBox control inside of a GridTemplateColumn and subscribing to the CheckedChanged event for it... The checkbox posts back when I click on it, but the event never gets fired...

Here's the code:

<telerik:RadGrid ID="rgPublicFields" runat="server" Skin="Vista"
    <MasterTableView AutoGenerateColumns="false"
        <Columns> 
            <telerik:GridBoundColumn UniqueName="PublicFieldID" DataField="PublicFieldID" Visible="false"></telerik:GridBoundColumn> 
             
            <telerik:GridTemplateColumn HeaderText="Include" UniqueName="Active"
                <ItemTemplate> 
                    <asp:CheckBox ID="cbInclude" runat="server" Checked='<%# System.Convert.ToBoolean(int.Parse(Eval("Active").ToString())) %>' Text='<%# Eval("PublicFieldID") %>' AutoPostBack="true" OnCheckedChanged="cbInclude_CheckedChanged" /> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
             
            <telerik:GridBoundColumn HeaderText="Field Name" UniqueName="FieldName" DataField="FieldName"></telerik:GridBoundColumn> 
             
            <telerik:GridTemplateColumn HeaderText="Display As" UniqueName="DisplayName"
                <ItemTemplate> 
                    <asp:TextBox ID="tbDisplayName" runat="server" Text='<%# Eval("DisplayName") %>'></asp:TextBox> 
                    <asp:Button ID="btnUpdate" runat="server" CommandName="UpdateDisplayName" CommandArgument="" Text="Update" /> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 

And the codebehind:

        protected void Page_Load(object sender, EventArgs e) 
        { 
            DataSet ds = new DataSet(); 
            ds.Tables.Add(); 
 
            ds.Tables[0].Columns.Add("PublicFieldID"); 
            ds.Tables[0].Columns.Add("Active"); 
            ds.Tables[0].Columns.Add("FieldName"); 
            ds.Tables[0].Columns.Add("DisplayName"); 
 
            ds.Tables[0].Rows.Add(new object[] { 1, 1, "Email""Email Address" }); 
 
            rgPublicFields.DataSource = ds; 
            rgPublicFields.DataBind(); 
        } 
 
        protected void cbInclude_CheckedChanged(object sender, EventArgs e) 
        { 
            CheckBox cb = (CheckBox)sender; // I have a breakpoint set here that never stops 
 
 
        } 

If anyone could help me identify why this is happening, it would be greatly appreciated.

3 Answers, 1 is accepted

Sort by
0
Ilija
Top achievements
Rank 1
answered on 24 Jul 2008, 09:27 PM
Thank you, this solved my problem.
0
Shinu
Top achievements
Rank 1
answered on 25 Jul 2008, 06:14 AM
Hi Ilija,

You can go through the following demo link to get more details about AdvanceDataBinding techniques.
Advanced data-binding

Thanks
Shinu.
Tags
Grid
Asked by
Ilija
Top achievements
Rank 1
Answers by
Vladimir
Top achievements
Rank 1
Ilija
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or