0
votes

How do i update gridView inside UpdatePanel. My delete button i okay. But I have to refresh page to see changes.

btn Button and litTest is for checking updatePanel.

I hope anyone can help me whats wrong...

 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
     <asp:UpdatePanel ID="UpdatePanel1" EnablePartialRendering="true" runat="server">             
        <ContentTemplate>
            <asp:Literal ID="litTest" runat="server" />
              <asp:GridView 
                ID="GridViewBruger"
                CssClass="TableSort"
                runat="server" 
                CellPadding="4" 
                GridLines="Horizontal"
                AutoGenerateColumns="False"
                width="500"
                onrowcommand="GridViewCase_RowCommand">
                    <Columns>
                        <asp:BoundField DataField="FilePath" />
                        <asp:BoundField DataField="File" ItemStyle-HorizontalAlign="Center" HeaderText="File" ItemStyle-Width="200px" HeaderStyle-CssClass="header"/>
                        <asp:BoundField DataField="Date" ItemStyle-HorizontalAlign="Center" HeaderText="Date"/> 
                        <asp:buttonfield buttontype="Image" ItemStyle-HorizontalAlign="Center"  ImageUrl="~/img/trash.png" commandname="Del" text="Slet" HeaderText="Delete"/>             
                    </Columns> 
                </asp:GridView>                         
        </ContentTemplate>
     </asp:UpdatePanel>

     <asp:Button ID="btn" Text="testUpdatePanel" runat="server" OnClick="btn_Click" />

Thanks!!

1

1 Answers

0
votes

By calling the GridViewBruger.DataBind() on code behind the GridView will be updated.

Also if you add the update button, inside the update panel, and on code behind also just call the DataBind() also the grid view will be updated.

.....
                </asp:GridView>                         
              <asp:Button ID="btn" Text="testUpdatePanel" runat="server" OnClick="btn_Click" />
        </ContentTemplate>
     </asp:UpdatePanel>