JoseSebastianGarcia-1349 avatar image
0 Votes"
JoseSebastianGarcia-1349 asked AlbertKallal-4360 commented

Ajax / Asynchronous - GridView (webforms)

Hello! I hope you are doing good! I am writing to you because surely you have already come across this need and I do not find much information about it by googling, what is more, I already have a laboratory, a custom control that solves the need, but I feel that I am reinventing the wheel so here is my query.

Giving maintenance to a legacy, I came across the need to asynchronously load a grid within a webform page (gridview grid or grid made with repeater), in principle for simplicity I prefer to have a separate custom control that I can reuse but I want to be able to use it both from code behind and from javascript because there are several cases to consider.

I would be grateful if you would tell me if you already know of something existing for this or if I continue with what I am putting together.

Objective: It doesn't matter how long the grid takes, I'm only interested in the page loading quickly, with the restriction of not being able to place indexes in databases.

Thank you very much,
best regards,

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JoseSebastianGarcia-1349 ,

First of all, the Q&A is currently only supported in English, so if possible, could you please edit your question in English, I think it would help community members to understand this issue and help resolve it.

Second, I tried to understand the problem using translations, but I'm still a bit confused about it. As far as I know, the DataGridView control is usually used in Windows Forms projects. The title and description of the question seem a bit confusing, I think you are referring to the GridView control in .NET WebControl, right?

If possible, could you describe your issue more clearly, thank you for your understanding. But if I misunderstood anything, just let me know.

0 Votes 0 ·

I've translated the message, thank you for your answer. Yes my problem is with asp:GridView

0 Votes 0 ·

1 Answer

AlbertKallal-4360 avatar image
0 Votes"
AlbertKallal-4360 answered AlbertKallal-4360 commented

Well, ok, several issues here.

You can (could) load the grid inside of a up-date panel. And you could make this up-date panel part of the user control.

it not clear if you need the gridview (gv) to load asynchronous to speed up page load time, or for some other reason?

Often the issue is not load speed of the gv, but of course wanting to eliminate the post-back. (since that will often say cause the browser to scroll - and thus using + working + selecting a item from a grid, then you lose your position on the page)

Loading a grid with some asynchronous method WILL NOT make the grid load faster.

However, you could say have the web page load first, and THEN have the gv load + display. So, the user will perceive a faster load time, since the page was displaying before the grid did.

However, time to load a gv should be VERY little. Even if the database has 1 million rows, your gv only going to display say 20 or 40 rows, and thus will and still should load instant.

So, if the gv load time is slow? Then fix that issue, and then all other issues go away


Ok, so the post 100% realizes the performance should be fixed - but the following should work well

Just remember to give that poor server a hug, ok? ;-)

so, add the script manager, and then drop in a update panel, then content template, and then YOUR gv inside.

Like this:


Note careful how we ALSO placed a button in the panel - when clicked on it will load up the gv. (we use client side code to click this button).

Also, I dropped in a progress panel. These are nice, since you don't have to write extra client side JavaScript to show/hide some kind of message
(or in my case a spinner gif).

My button code to load gv is this - not really all that important


Note for above - REMOVE that fake delay i have - this was just for testing to slow down the gv for this example.

Ok, last but not least, we add a wee bit of js code - right at the bottom of the web page - (right before form tag, or content tag (if a page inside master page).

So then this:


so, like all page loads with code behind, you ONLY EVER load up those controls inside of a IsPostBack = false right?
(since if you don't, then any button click or anything else you do on that page will trigger a re-load of the gv).

So, above works very nice. The page will render, display, and then the gv will load.

Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada

image.png (53.5 KiB)
image.png (44.1 KiB)
image.png (23.0 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The goal would be to optimize page load speed by placing grids loading asynchronously.

The customer is not flexible in indexing the database

I don't care how long it takes to load the grid, for now what interests me is that the page loads fast.

0 Votes 0 ·
AlbertKallal-4360 avatar image AlbertKallal-4360 JoseSebastianGarcia-1349 ·

Ok, see my edit and suggested code above.

0 Votes 0 ·