Question : asp.net show gridview loading after page is loaded

This is really hard to explain.

But what i have now is a page that had a gridview on it.  The gridview takes approx 30-45 seconds to load. (10,000 rows x 12 columns)

What i want to happen is to have the page completely load first then bind the gridview so it shows the loading dialog.

Currently i have an update panel showing when a user clicks to sort, edit, or update. but i would really like it to show up when the page is first loaded.

Is this possible?


asp.net 3.5
iis 6
VB

Answer : asp.net show gridview loading after page is loaded

So I put together a sample, and tested. Your idea was very good. I just simplified it for you.

1) Attach JS event to body onload event
2) Fire __doPostBack() from this event so the grid doesn't load until the rest of th epage loads
3) Grid has no datasource initially
4) Grid is in updatepanel so it is the only thing that relads on __doPostBack()
5) Assign gridview's datasource from the __doPostBack() from the code-behind

NOTE: You can still add in the niceties like the "waiting" animation or whatever and all should work fine.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
****ASPX PAGE SAMPLE***
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>GridView Tricks</title>
<script type="text/javascript">

function initGrid()
{
	//Once Page Loaded Setup GridView DataSource/Bind
	//The timeout is completely unnecessary, but helpful in showing that it works since otherwise
	//in my environment it will run too quickly and I don't want to setup an animation :)
	setTimeout(function(){__doPostBack($get('up').id,'true');},2000);
	
	//__doPostBack($get('up').id,'true');
}

</script>
</head>
<body onload="initGrid();">
    <form id="form1" runat="server">
		<h5>Just Something To See While I Wait For The Grid</h5>
		<asp:ScriptManager ID="sm" runat="server" Enablepartialrendering="true" />
		
		<asp:UpdatePanel ID="up" runat="server">
			<ContentTemplate>
			<%--NOTE: There is no datasourceid set on the gridview initially, we set that in code-behind--%>
			<asp:GridView ID="GridView1" runat="server" />
			<asp:SqlDataSource ID="sqlDS" runat="server"
				ConnectionString="Data Source=WT101\SQLEXPRESS;Integrated Security=True"
				SelectCommand="SELECT * FROM DevTable" />
			</ContentTemplate>
		</asp:UpdatePanel>
    </form>
</body>
</html>


****CODE BEHIND****
    protected void Page_Load(object sender, EventArgs e)
    {
        //I got a little carried away on the "null" checking
        //more out of habit than necessary for this scenario
        if(!string.IsNullOrEmpty(Request.Params.Get("__EVENTARGUMENT")))
        {
            //If I sent the postback from JavaScript initGrid() function then
            //Assign the gridview its datasource and all the rest takes care of itself
            if(Request.Params.Get("__EVENTARGUMENT") == "true")
            {
                GridView1.DataSourceID="sqlDS";
            }
        }
    }
Random Solutions  
 
programming4us programming4us