UpdatePanel与GridView和Progressbar不工作

本文关键字:工作 Progressbar GridView UpdatePanel | 更新日期: 2023-09-27 18:11:40

我需要帮助。我有一个进度条,点击按钮后触发。此按钮在SQL中运行存储过程,该过程将更新稍后为gridview绑定的表,在运行存储过程后,我执行代码以更新gridview。问题是,在进度条出来后,我期望网格视图会自动刷新/更新,但它没有发生。请帮助。

ASPX - GridView:

<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<asp:UpdatePanel ID="UpdatePanel9" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                    <table cellpadding="0" cellspacing="0">
                        <asp:GridView ID="GridExportExcel" runat="server" >
...........Blah
                    </table>
            </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnExecSP" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
</asp:Panel>

ProgressBar:

<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="false">
            <ProgressTemplate>
                <asp:Image ID="loading" runat="server" ImageUrl="loading.gif" />
            </ProgressTemplate>
        </asp:UpdateProgress>

Code Behind from button: -此存储过程运行约3分钟。

 DataTable dt = new DataTable();
            GridExportExcel.DataSource = dt;
            GridExportExcel.DataBind();
            //UpdatePanel9.Update();
            string connectionString = WebConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString;
            string selectSQL = "exec dbo.StoredPRoc'" + txtcomp.Text + "','" + TextBox2.Text + "'";

            DataTable DT = new DataTable();
            DT = ExecGetData(selectSQL);
            header(); //Update the Gridview.

Thank You -还建议


嗨,布莱恩,谢谢你的回复。我不允许在表中创建索引。我做了一些工作,并删除了进度条,它工作得很好,虽然查询/存储过程仍然在3分钟内执行。网格视图正在更新中。如何在不超时的情况下显示进度条?有什么办法可以做到吗?感谢您的回复。

UpdatePanel与GridView和Progressbar不工作

很可能您超时了,因此新结果没有返回。要验证这一点,请尝试绑定到只需要运行几秒钟的测试查询,并查看结果是否从该查询返回。如果它为真,那么它就是查询。

是否可以提高查询的效率,比如应用索引,或者使用其他查询方法?对于一个web应用程序来说,3分钟的运行时间太长了。