locked
Update Panel Not Working - ASP.NET RRS feed

  • Question

  • User-341437093 posted

    Hey all,

    This is my first post so hope everyone is ok and keen to help a person just joined!

    I have added an update Panel around my Table and added a trigger button, but it seems to always update on post back. 

    My requirements are;

    • Update on ititial Page Load
    • Do not update on PostBack

    This is my ASP.NET Code

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    
        <asp:Button ID="Button1" runat="server" Text="Button" />
    
    
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional"> 
    
                    <Triggers>
                        <asp:PostBackTrigger ControlID="Button1" />
                    </Triggers>
    
    <ContentTemplate> 
        
        <asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" CssClass="Grid" AlternatingRowStyle-CssClass="alt"
            DataKeyNames="UserName" OnRowDataBound="OnRowDataBound">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <img alt = "" style="cursor: pointer" src="../images/plus.png" />
                        <asp:Panel ID="pnlOrders" runat="server" Style="display: none">
                            <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass = "Grid" OnRowCommand="OnRowCommand">  
                                <Columns>
                                    <asp:BoundField ItemStyle-Width="150px" DataField="UserID" HeaderText="UserID" />
                                </Columns>
                            </asp:GridView>
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField ItemStyle-Width="200px" DataField="UserName" HeaderText="UserName" />
                <asp:BoundField ItemStyle-Width="200px" DataField="Access" HeaderText="Access" />
                <asp:BoundField ItemStyle-Width="200px" DataField="FullName" HeaderText="Name" />
            </Columns>
        </asp:GridView>
            
        <br />
        <br />
        <br />
        <br />
        <script type="text/javascript" src="../jquery/jquery-1.8.3.min.js"></script>
    
            <script type="text/javascript">
                $("[src*=plus]").live("click", function () {
                    $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
                    $(this).attr("src", "../images/minus.png");
    
                });
    
                $("[src*=minus]").live("click", function () {
                    $(this).attr("src", "../images/plus.png");
                    $(this).closest("tr").next().remove();
                });
    
        </script>
                  
        </ContentTemplate> 
        
        </asp:UpdatePanel> 

    On my page i have added the background code in VB.NET

            If Not IsPostBack Then
    
                Dim strSQL As String
                strSQL = "SELECT UserName, UserName, Access, FullName "
                strSQL = strSQL & "FROM TblDefaultUsers "
    
                gvCustomers.DataSource = GetData(strSQL)
                gvCustomers.DataBind()
    
            End If

    Any ideas.

    Thank you

    Jason

    Wednesday, April 17, 2019 11:51 AM

All replies

  • User-2054057000 posted

    Are you trying to perform asynchronous operations on GridView by using Update Panel? If this is the case then I suggest you to put your GridView inside the Update panel.

    Thursday, April 25, 2019 10:57 AM