3

我想在我的 gridview 填充数据时在我的 asp.net 网页中显示一个加载指示器

这是我的 aspx 页面的一部分

    <script type="text/javascript" src="Scripts/jsUpdateProgress.js"></script>      
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress">
        <asp:UpdateProgress ID="UpdateProg1" DisplayAfter="0" runat="server">
            <ProgressTemplate>
                <div style="position: relative; top: 30%; text-align: center;">
                    <img src="Styles/images/loading.gif" style="vertical-align: middle" alt="Processing" />
                    Loading...
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </asp:Panel>
    <ajaxToolkit:ModalPopupExtender ID="ModalProgress" runat="server" TargetControlID="panelUpdateProgress"
        BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress" />

(我的代码基于这个示例 weblogs.asp.net/blogs/guillermo/Code/modalExample.zip)

这是我调用我的方法的按钮

<asp:UpdatePanel ID="updatePanel" runat="server">
        <ContentTemplate>
            <asp:Button ID="btMonth" runat="server" onclick="btMonth_Click" Text="Ver" />
        </ContentTemplate>
    </asp:UpdatePanel>

这是我的方法 btMonth_Click 的 c# 代码

    protected void btMonth_Click(object sender, EventArgs e)
{
    string query = "select * from table";
    SqlDataSource1.SelectCommand = query;
    gInd.DataSourceID = "SqlDataSource1";
}

正如您所看到的,当“加载”指示器出现时,我想填充一个 GridView,但是当我单击按钮时,会调用方法 btMonth_Click,该方法被执行,但我的 gridview 没有被填充。如果我删除我的按钮的 asp:UpdatePanel 我的 gridview 填充得很好

有什么我想念的吗?

4

2 回答 2

2

您需要将您的GridVew内部放置UpdatePanel以进行部分渲染

如果出于设计原因您不能将网格放在第一个 UpdatePanel网格内,您可以有几个UpdatePanel

欲了解更多信息:

如何在同一个 .aspx 页面上使用两个更新面板

于 2012-07-24T20:26:59.513 回答
0

尝试添加:

gInd.DataBind();

在您的 btMonth_Click 中(顺便说一句。更好的命名约定是 btnMonth_Click)

    protected void btMonth_Click(object sender, EventArgs e)
{
    string query = "select * from table";
    SqlDataSource1.SelectCommand = query;
    gInd.DataSourceID = "SqlDataSource1";
    gInd.DataBind();
}
于 2012-07-24T20:26:58.727 回答