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.