Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Improving HTML performance of DataGrids

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
0
0
US
I'm looking for ways to improve the HTML performance of ASP.NET webpages using scrollable DataGrids... The larger the datagrid, the longer it takes for the webpage to display with the grid. That blank white page displaying for a few seconds between displays of the webpages can be annoying.

Supposedly if I were able to remove as much whitespace between HTML tags as possible and use as few HTML & web controls as possible, the performance should improve somewhat, so I've heard. Does anyone know of a way or DataGrid etc properties to force the HTML code auto-generated by the datagrid to do this?

Example of auto-generated HTML of a datagrid:
<tr>
<td>table data 1</td>
<td>table data 2</td>
</tr>
<tr>
<td>table data 3</td>
<td>table data 4</td>
</tr>

change to

<tr><td>table data 1</td><td>table data 2</td></tr><tr> <td>table data 3</td><td>table data 4</td></tr>

Any ideas would be appreciated - changing from a scrollable grid to a page-number grid or forcing a small amount of data to show on the datagrid are not really options that I'd want though. Thanks.
 
You might want to check the indexes on the fields in the table and make sure that the query used to retrieve the data is as efficient as possible. Stored Procedures can be faster as well. Since .Net writes the HTML code I don't think that you can change it.

Also when you are working on a live site. Change the Web.Config to

Code:
    <compilation defaultLanguage="vb" debug="false"></compilation>

Hope everyone is having a great day!

Thanks - Jennifer
 
The only way I know of to get the HTML to change would be to override the Render method of the datagrid... very unadvisable, because you have basically put yourself right back into the CLASP days of when you would have had to "roll your own" datagrid. Didn't see too many datagrids in those days, did you?

To be honest, I don't think it would yield much (if any) performance gain anyway, since the entire table would still have to render before anything displayed in the browser.

Unfortunately, it's the nature of the beast. I would follow JZelhart's advice, and maybe implement paging or something else that will reduce the size of the rowset being returned.

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Thanks, JZelhart & link9. I'll find out what I can about overriding the Render method to minimize the size of the HTML tags but link9 is likely right. Maybe I can remove what hidden variables, controls etc I can but I suspect I'll get nada out of this.

It would seem that for read-only grids, the Java GridControl might have a performance edge for large grids over .NET's datagrid since I don't experience this problem with the Java GridControl. But then I don't think the GridControl has the edit capabilities of .NET's editable datagrid (correct me if I am wrong here). Win some, Lose some. :)

There's always the option to use .NET's equivalient of ASP 3.0's Flush(? been a while since I did that) but it probably won't work with a datagrid. I'll find out.

Any ideas pop up, post them here! Thanks.

 
If it's a readonly grid, you'll also get a performance boost out of setting:

EnableViewState="false"

Actually, this is true for all controls. You lose the advantages of ViewState (obviously), but this is one of the biggest causes of slow ASP.NET pages.

-p

ps. Don't waste your time trying to override the Render method of the DataGrid. I only said that to illustrate the point that you can't get better HTML out of the datagrid.

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top