smilu
smilu

Reputation: 899

Postback Happening inside UpdatePanel when CheckBox is Checked

I have a ListView and inside it I'm having a CheckBox for which AutoPostBack is set to true, I also have a Collapsible panel kept inside the same ListView adjacent to this CheckBox.

The entire thing is kept inside an UpdatePanel for Silent Post back. Now my problem is even though it is kept inside a UpdatePanel when I click on the CheckBox the Entire page is getting Refreshed. I need to do it using a Silent PostBack. How can i Achieve this??

<asp:ListView ID="ListViewGroups" runat="server" 
        onitemdatabound="ListView1_ItemDataBound">


    <EmptyDataTemplate>
        <table runat="server" style="">
            <tr>
                <td>
                    No data was returned.</td>
            </tr>
        </table>
    </EmptyDataTemplate>

    <ItemTemplate>
        <tr style="">
            <td>
            <asp:Panel ID="PanelContainer" runat="server" Width="400px">

                <asp:Panel ID="PanelHeaderList" runat="server" Width="20px">
                <div style="float:left;" >
                <asp:ImageButton ID="Image1" runat="server" 
                                 ImageUrl="~/expand_blue.jpg" 
                                 AlternateText="(Show Details...)"/>
                </div>
                 </asp:Panel>
                <div style="float:left;" >       
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                                  AutoPostBack="true" />            
                <asp:Label ID="Grp_NameLabel" runat="server" 
                           Text='<%# Eval("Grp_Name") %>' />
                <asp:HiddenField ID="hfGrpID" runat="server" 
                                 Value='<%#Eval("Grp_ID") %>' />
                </div>
              <br />
                <p>
                <asp:Panel ID="PanelGroupsItem" runat="server" 
                           Width="100px" >
                <asp:Panel ID="MyGroups" runat="server" 
                           ScrollBars="Vertical" 
                           Height="200px" 
                           Width="300px" 
                           Visible='<%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %>'>

                   //Another Normal gridView here just showing some data


                   </asp:Panel>
                </asp:Panel>

                <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
                                  runat="server"
                                  Collapsed="true"
                                  TargetControlID="PanelGroupsItem"
                                  CollapseControlID="PanelHeaderList"
                                  ExpandControlID="PanelHeaderList"
                                  ImageControlID="Image1"
                                  ExpandedImage="~/collapse_blue.jpg"
                                  CollapsedImage="~/expand_blue.jpg"
                                  SuppressPostBack="true"
                >
                </asp:CollapsiblePanelExtender>
                </asp:Panel>
                </p>
            </td>

        </tr>
    </ItemTemplate>
    <LayoutTemplate>
        <table runat="server">
            <tr runat="server">
                <td runat="server">
                    <table ID="itemPlaceholderContainer" runat="server" 
                           border="0" style="">
                        <tr runat="server" style="">
                            <th runat="server">
                                Groups</th>

                        </tr>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </table>
                </td>
            </tr>
            <tr runat="server">
                <td runat="server" style="">
                </td>
            </tr>
        </table>
    </LayoutTemplate>

</asp:ListView>

Please help me on this

Upvotes: 0

Views: 5110

Answers (1)

jhfelectric
jhfelectric

Reputation: 582

I found the solution for a similar issue here: Checkboxlist inside UpdatePanel triggers full postback when an item is checked.

You need to set the ClientID mode of the checkBox to AutoID.

Upvotes: 2

Related Questions