UpdatePanel causing full postback. Trying to do a partial postback

21,780

UpdatePanel.Triggers is made for this!

Take a look at it here: Understanding UpdatePanel.Triggers

Share:
21,780
shenn
Author by

shenn

Updated on July 09, 2022

Comments

  • shenn
    shenn almost 2 years

    I am working on a page that is using a gridview to display data. I have some dynamically created textboxes inside an ItemTemplate which contains several textboxes per row. Now I also have an update panel that is using ajax and should only render once my link button is clicked. The datalist is bound in my code behind after the I would like this to occur without causing a full postback. However, right now when I click the link button it causes a full post-back which eliminates my dynamically created controls.

    I feel I am very close to a solution. I need one of these to happen (option 1 seems more useful): Do not cause a postback when the linkbutton is clicked, but still render my full datalist in the update panel

    or

    my dynamically created controls are not removed during post back.

    Here is my code:

     <ItemTemplate>
            [&nbsp;<asp:LinkButton ID="SelectCommand" CommandName="Select"  runat="server" Text="+" CssClass="sunocoBold"/>&nbsp;]
            <%-- start sub panel--%>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
            <ContentTemplate>
    
                <asp:DataList ID="DataList1" runat="server" RepeatDirection="Vertical" 
                 OnItemCommand="DataList_OnItemCommand"> 
                <ItemTemplate>
                <asp:LinkButton ID="Select" CommandName="SelectCommand" CommandArgument='<%#Eval("ship_to_num")%>'  runat="server" Text='<%#Eval("ship_to_num")%>'  />
                 </ItemTemplate> 
                </asp:DataList> 
    
            </ContentTemplate>
            </asp:UpdatePanel> 
            <%-- end sub panel--%>
        </ItemTemplate>
    
    
    
      <asp:TemplateField HeaderText="Site Owner"  ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top"> 
        <ItemTemplate>
          <asp:Panel ID="pnlNames" runat="server">
            </asp:Panel>
          <%-- <asp:Literal ID="NameList" runat="server" /> --%>
        </ItemTemplate> 
        </asp:TemplateField>