UpdateProgress 中的 ProgressBar 在获取数据之前一直过期

ProgressBar in UpdateProgress keeps expiring before the data is fetched

我有一个 GridView,它显示了一些数据,并且在最后一列中有一个 Button,它结合了其他 3 个列的值。 只需在 rowCommand.

中调用此函数 GridData 即可轻松刷新 GridView
    protected void GridviewProcess_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "More")
            {
                objENT = new ENT();

                int index = Convert.ToInt32(e.CommandArgument.ToString());
                Label locCode = (Label)GridviewProcess.Rows[index].FindControl("lbl0");
                Label SurveyNo = (Label)GridviewProcess.Rows[index].FindControl("lbl2");
                Button Combine = (Button)GridviewProcess.Rows[index].FindControl("btnCombine");

                Combine.Enabled = false;
                objENT.LocationCode = locCode.Text;
                objENT.SurveyNumber = SurveyNo.Text;
                objENT.ProcType = "CREATECUSTOMER";
                DataSet ds = new DataSet();
                ds = BLL.CdCustomer(objENT);


            }

        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Some Error occurred Please refresh the page')", true);

        }
        finally
        {
            Griddata();
        }

    private void Griddata()
    {
        objENT.ProcType = "PAGEGRIDDATA";
        DataSet ds = BLL.ProcessGrid(objENT);
        string check = ds.Tables[0].Rows[0]["TOTAL_CUSTOMER"].ToString();


        GridviewProcess.DataSource = ds.Tables[0];
        ViewState["Grid"] = ds.Tables[0];
        GridviewProcess.DataBind();
    }

之后,我添加了这个ProgressBar

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
                            <ProgressTemplate>
                                <img src="images/progress_bar.gif" style="max-width: 250px" />
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                            <ContentTemplate>
                                <asp:GridView ID="GridviewProcess" AllowPaging="true"   CssClass="GridHeader" PagerSettings-Mode="NextPreviousFirstLast"  PagerSettings-PreviousPageText="<-Prev  " PagerSettings-Visible="true" PagerSettings-NextPageText="  Next->"
                                     PagerSettings-FirstPageText="<=FirstPage  " PagerSettings-LastPageText="  LastPage=>"     PagerStyle-Font-Bold="true" 
                                     OnPageIndexChanging="GridviewProcess_PageIndexChanging" PageSize="12" OnRowDataBound="GridviewProcess_RowDataBound" OnRowCommand="GridviewProcess_RowCommand" runat="server" Style="text-align: center"  Width="99%"
                                    AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Total Customers" HeaderStyle-BackColor="#99CCCC">
                                            <ItemTemplate>
                                                <asp:Label ID="lbl7" runat="server" Text='<%# Eval("TOTAL_CUSTOMER") %>'>

                                                </asp:Label>
                                                <asp:Button ID="btnCombine" CssClass="btn-primary btn" Text="Combine"
                                                    CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="More"
                                                    Style="padding-top: 1%; padding-bottom: 1%; margin-top: 1px; margin-bottom: 1px" runat="server" />

                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>

                                </asp:GridView>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnAddi" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>

ProgressBar 会显示,但调用函数 GridData(){} 后,它不会刷新 GridView。 我只能在刷新整个页面后才能看到更改。 我不明白怎么了... 我没有任何 JSCSS 用于此 ProgressBar..(这是问题吗?)

在 SO 问题上找到问题的解决方案

UpdateProgress Timed Out before data could be processed

实际问题是: 我的 ASP.NET 页面上有一个按钮,它从我的数据库中获取一些数据并将其显示在 GridView.

这个过程需要一段时间,所以我想我会添加一个 updateprogress AJAX 控件。现在,当我单击该按钮时,将显示 UpdateProgress 图像,并且已成功从我的数据库中获取数据(我从我的数据库中的一些日志中检查了这一点)。但是有两个问题:

UpdateProgress 图片只显示了大约 2 分钟。但是我的 ButtonClick 事件大约需要 5 分钟才能完成。基本上 UpdateProgress 甚至在我的任务完成之前就停止出现,这违背了它的目的。

正如我在其中一个 SO 答案中发现的那样

根据问题很可能是 ajax 超时。默认超时为 90 秒。要增加使用 ScriptManager's AsyncPostBackTimeout 属性:

<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="400">
</asp:ScriptManager>

如果 AJAX 调用超时,页面上的控件可能无法正常工作,因此增加超时也可能会解决问题 (2)。