【问题标题】:Gridview inside updatepanel更新面板内的 Gridview
【发布时间】:2013-12-22 15:31:38
【问题描述】:

如何在 UpdatePanel 中更新 gridView。 我的删除按钮没问题。但我必须刷新页面才能看到更改。

btn Button 和 litTest 用于检查 updatePanel。

我希望任何人都可以帮助我有什么问题...

 <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" />

谢谢!!

【问题讨论】:

    标签: asp.net gridview updatepanel


    【解决方案1】:

    通过调用GridViewBruger.DataBind() 上的代码,GridView 后面的代码将被更新。

    此外,如果您在更新面板内添加更新按钮,并且在后面的代码上也只需调用 DataBind(),网格视图也会被更新。

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

    【讨论】:

    • 谢谢。我试过让我在 UpdatePanel 之外的控件停止工作。我有一个 asp:AjaxFileUpload ??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 2018-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多