65.9K
CodeProject is changing. Read more.
Home

Tips using DataGrids

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.17/5 (7 votes)

Feb 12, 2007

1 min read

viewsIcon

11667

Tips on using DataGrids when programming using .Net

ASP.NET Performance when using DataGrid

I am here to give you three tips whn using Grids when developing web applications using asp.net 1.1. When I was developing my web site www.arabiahotjobs.com I faced almots every problem a software developer will encounter while developing SDLC projects.

these are a few tips using Grids you should consider

1- Try not to use Column Bound instead use ItemTemplate when its possible. Using itemTempalte you will have a full control over the server controls. On the DataGrid ItemDataBound event you can control the formate or validate/change the content of items to be displayed.

2- If the data returend by the Dataset to the DataGrid are 1000's of records for 1000's of users try to use Data readers and Paging rather than adapters and datasets. you can search this website on Paging.

3-Grid's viewstate takes almost double size of the remaining page on bytes. try to set viewstate = false when its possible. Remeber that you do not need to PostBack
when you are navigating from one page to others independantly.

4- Make sure bind the Data in a function call BindData() and only to be called on
If (!PostBack) { BindData(); };
Otherwise you will end-up bing every page postback even if you are redirecting to another page.

5- if you grid is in the main (default) page and is only can be changed occationally (a few times a day) for example (HotJobs of the week), try to use a grid inside a cashed usercontrol (say to be cahed every 4 hours)

I hope that these tips will help you.

Nahed Kadih
Jobs in Middel East
www.arabiahotjobs.com
Software Architect