views:

135

answers:

2

I have a Data Grid and an Update Panel. Now, I was just looking over some blogs and found that you should use the least amount of Update Panels as you can. In my case, where I have a Datagrid and an Update Panel, which would be the best situation?

1) Keep the Datagrid inside the Update Panel.

2) Use an Update Panel inside ItemTemplates. So that only if I update only the selected row is updated not the whole grid.

+1  A: 

If performance is your goal, start with the DataGrid. The amount of garbage it stores in viewstate is amazing.

UpdatePanel's in and of themselves aren't anywhere near as bad as a DataGrid.

Chris Lively
Well I know about the garbage it stores. But, I need this for now. So, in the current context what would be the best option for me?
Mohit
No matter what you do, when using updatepanels the entire viewstate is going to be submitted back anyway. So, either stick with item 1 because it's less code to maintain and easier to figure out any problems; or, 2 get rid of update panels completely in favor of a different approach. And by different approach I mean NOT using the .Net version of Ajax.
Chris Lively
I just thought of one more option. Use JSON requests instead. This will result in a much smaller amount of traffic going between the browser and the server. http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/
Chris Lively
+2  A: 

Unfortunately, unless your DataGrid is very large, it won't make much difference either way.

The majority of your overhead is usually in reinstantiating the Page. Even if your UpdatePanel is only sending back one rendered row, the entire Page, including the entire DataGrid, must be re-created and rendered before the pertinent section of HTML can be extracted and sent back to the browser.

If what you have is working, I'd leave it alone and concentrate any ongoing efforts on a more client-centric approach, which is where huge performance gains are to be had.

Dave Ward
Hey Dave, how are you?Yes, my datagrid is large. And that's why I am asking this question. What would be your suggestion?Should I use Update Panels now or move towards jquery or JSON?Please help me.
Mohit
For performance, a client-side technique (jQuery, JSON, etc) is definitely the way to go. There is no way to make an UpdatePanel perform comparably on a complex/large page.
Dave Ward