views:

1300

answers:

2

I am trying to determine why an asp.net grid view is so horribly slow. The grid view is contained in a custom sub class that adds a custom pager and does some special formatting. Further, the custom grid view is contained in a user control that puts the grid view in an update panel and combines it with an object data source to making the control easy to use.

I have traced the slow downs to two problem areas:

  • The first is the size of the rendered html and viewstate. I managed to improve this by rendering viewstate to a session variable instead of the hidden field, but I may rewrite the control to not use viewstate at all.
  • But, my main problem is the rendering of the control. On a simple page where the only control is my user control rendering a 40 cols x 20 rows grid takes several seconds even with viewstate disabled! Looking at the trace I found that the PreRender stage takes 95% of the time, so I assume the problem is there.

So, my question is how should I fix this? I am having problems tracing what asp.net does inside the PreRender stage. I have some code in the user control that is called but most of the time is spent outside my code.
I tried downloading the debug symbols for asp.net but Visual Studio still won't let me step into the code, and the trace is not giving too much information here.

Have anybody else been in this situation? I first suspected my data source, but the database call is fast so the problem is not there.

+4  A: 

Try a profiler such as ANTS or dotTrace - both have free evals, or Team System has one if you're licensed for it (Partner?). They'll show you where the time is being consumed or at least help you clarify where to look.

And listen to Rico Mariani in the recent Deep Fried Bytes podcast - the best 40 mins you'll ever spend.

Ruben Bartelink
I just ran a trace of the web application and the results were very interesting! It appears that the problem is not what I thought it would be. Thanks!
Rune Grimstad
Wahey, me gets me badge for me first accepted answer :PSeriously, the podcast is well worth a listen (as is Rico's blog)
Ruben Bartelink
Thanks! (Newbies heh!)
Ruben Bartelink
+1 for and old friend. Nice to see you here Dude :) Mark Lysaght
Binary Worrier
A: 

Rune,

Can you explain what interesting results did you find?

I have been facing the same problem as yours and I still think it's down to the large size of the grid (Even without the Viewstate) which is bogging down my site.

Have you found any workarounds for this?

Hi. You should use comments for questions like this... :-) But what I found out was that while the Viewstate was a problem, the main problem was other places in the code. Caching helped a lot and some rewrites and optimizations of the code also helped. On top of that we added a few extra gigabytes of ram and an extra cpu to the server.
Rune Grimstad