Frost_Mourne Frost_Mourne -4 years ago 99
ASP.NET (C#) Question

How to refresh the Gridview after showing ProgressBar

I have a

which shows some data and has a
in the last column that combines the value of the 3 other columns.
I was able to refresh the
easily just by calling this Function
in the

protected void GridviewProcess_RowCommand(object sender, GridViewCommandEventArgs e)
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;
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);


private void Griddata()
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];

After,I added this

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
<img src="images/progress_bar.gif" style="max-width: 250px" />
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<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%"
<asp:TemplateField HeaderText="Total Customers" HeaderStyle-BackColor="#99CCCC">
<asp:Label ID="lbl7" runat="server" Text='<%# Eval("TOTAL_CUSTOMER") %>'>

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


<asp:AsyncPostBackTrigger ControlID="btnAddi" EventName="Click" />

will show but after the function
{} is called it wont refresh the
I can see the changes only after,I refresh the whole page.
I don't understand whats going wrong...
I don't have any
used for this
..(Is that the problem?)

Answer Source

Found the Solution to the Problem on SO questions UpdateProgress Timed Out before data could be processed Actual problem was : I have a button on my ASP.NET page, which fetches some data from my database and displays it on a GridView.

This process takes a while, so I thought I'll add an updateprogress AJAX control. Now when I click the button, the UpdateProgress Image shows up and data is being fetched from my database successfully (I checked this from some logs that I have in my DB). But there are 2 issues:

The UpdateProgress image shows only for about 2 minutes. But my ButtonClick event takes about 5 minutes to complete. Basically the UpdateProgressstops showing up even before my task is complete, which defeats its purpose.

As I found this in one of the SO Answers

As per issue most likely it is ajax timing out. Default timeout is 90 seconds. To increase that use ScriptManager's AsyncPostBackTimeout property:

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

If AJAX call is timing out, controls on the page might not work correctly so increasing timeout might solve problem (2) as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download