[RESOLVED]how to append form for a checkbox in Gridivie within Accrodion

Hi,

I have a GridView inside a JQuery accordion panel. Each row of the GridView has a CheckBox with AutoPostabck enabled. The event is not firing I believe because as usual ASP.Net forms elements need to be appended to the form but I am not sure how to dot for
each checkbox in Gridview Row. How do i execute Jquery

  $('<%# CheckBox1.ClientID %>).parent().appendTo("form");

when every row is data bound?

Thanks

Hi mhariri,

Thanks for your post.

mhariri

I have a GridView inside a JQuery accordion panel. Each row of the GridView has a CheckBox with AutoPostabck enabled. The event is not firing

Firstly, I create a demo to reproduce your problem, the below code works fine on my side. So you compare your code with the following sample to find some differences.

<form id="form1" runat="server">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
        <div>
            <asp:Accordion ID="Accordion1" runat="server">
                <Panes>
                    <asp:AccordionPane ID="AccordionPane1" runat="server">
                        <Header>
                            Item1
                        </Header>
                        <Content>
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1">
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox2_CheckedChanged"/>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
                                    <asp:BoundField DataField="Values" HeaderText="Values" SortExpression="Values" />
                                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                </Columns>
                            </asp:GridView>
                        </Content>
                    </asp:AccordionPane>
                </Panes>
            </asp:Accordion>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [ChartInfo]"></asp:SqlDataSource>
        </div>
</form> 
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
        {
            //bool ischecked = ((CheckBox)sender).Checked;
            string rows = ((GridView)AccordionPane1.ContentContainer.Controls[1]).Rows.Count.ToString();
        } 

Secondly, you could show us your complete code, it wil help us understand your problem and fix it.

If you have any question about my reply, please let me know.

Best Regards,

Fei Han

Leave a Reply