Click here to Skip to main content
15,882,329 members
Articles / Database Development

Displaying Update progress at center of gridview

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Oct 2013CPOL3 min read 18.3K   1  
In this article I am explaining about how to show Loading... image using Update Progress at center of grid view. for  this article i have used North

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

In this article I am explaining about how to show Loading... image using Update Progress at center of grid view. for  this article i have used North wind database to bind grid view

Aspx code

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="System.Web.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"

    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head runat="server">

    <title>Update Progress Sample</title>


    <script type="text/javascript">

        function onUpdating() {

            var updateProgressDiv = document.getElementById('upCustomer');

            var gridView = document.getElementById('gvUpdateProgress');


            var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);

            var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);


            var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);

            var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);


            Sys.UI.DomElement.setLocation(updateProgressDiv, x, y);  





    <form id="frmUpdateProgress" runat="server">


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


        <table border="0" cellpadding="0" cellspacing="0" width="100%">



                    <td align="center" style="font-family: Calibri; background-color: #3366CC; color: #FFFFFF;

                        visibility: hidden; width: 100%">

                        UpdateProgress Sample




                    <td style="border: medium dotted Navy; font-family: Calibri; color: Purple; width: 100%;

                        border-color: Red; border-top-width: thick;">

                        <asp:UpdateProgress ID="upCustomer" AssociatedUpdatePanelID="upnlCustomer" runat="server">


                                <div id="imgdivLoading" align="center" valign="middle" runat="server" style="border-style: dotted;

                                    padding: inherit; margin: auto; position: absolute; visibility: visible; vertical-align: middle;

                                    border-color: #000066 black black black; border-width: medium">

                                    <asp:Image ID="imgLoading" runat="server" ImageUrl="Images/loading.gif" Width="34px" />Loading...
















                    <td style="width: 100%">

                        <asp:UpdatePanel ID="upnlCustomer" runat="server">


                                <asp:GridView ID="gvUpdateProgress" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"

                                    AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" Font-Names="Calibri"

                                    OnPageIndexChanging="gvUpdateProgress_PageIndexChanging" Width="100%" Caption="UpdateProgress Sample">

                                    <RowStyle BackColor="#EFF3FB" />


                                        <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />

                                        <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />

                                        <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />

                                        <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />

                                        <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" />

                                        <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />

                                        <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />


                                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

                                    <PagerStyle BackColor="#2461BF" BorderStyle="None" ForeColor="White" HorizontalAlign="Right"

                                        Height="15px" />

                                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

                                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

                                    <EditRowStyle BackColor="#2461BF" />

                                    <AlternatingRowStyle BackColor="White" />












C# code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Data;

using System.Data.SqlClient;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class _Default : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)


        gvUpdateProgress.Attributes.Add("onclick", " onUpdating();"); // adding java script to grid view.




/// Getting Customer table data from North wind database to bind gridview
/// </summary>
private void bindGrid()
SqlConnection conn = new SqlConnection("Trusted_Connection=yes;Addr=Localhost;Initial Catalog=Northwind");
SqlCommand cmdCustomer = new SqlCommand("SELECT [CustomerID],[CompanyName],[ContactName],[City],[PostalCode],[Country],[Phone] FROM Customers", conn);
SqlDataAdapter adptCustomer = new SqlDataAdapter(cmdCustomer);
DataSet dsCustomer = new DataSet();
gvUpdateProgress.DataSource = dsCustomer.Tables[



/// <summary>


/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>


    protected void gvUpdateProgress_PageIndexChanging(object sender, GridViewPageEventArgs e)


        System.Threading.Thread.Sleep(3000); // Loading image waiting period

        gvUpdateProgress.PageIndex = e.NewPageIndex;




This article is for single gridview controls. If we have more than one gridviews in your page we have to change javascript. If you have any concerns and comments please write to me.

Hope this example helps you.  Happy coding.

Srinivas Kotra. 






This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
This is a Collaborative Group

754 members

Comments and Discussions

-- There are no messages in this forum --