Showing posts with label grid. Show all posts
Showing posts with label grid. Show all posts

Wednesday, March 28, 2012

UpdatePanel - Single GridView row

I have a GridView where the database query is rather slow. I would like to use the UpdatePanel when editing a single row. Placing the entire grid inside of an UpdatePanel causes the entire grid to bind to the data source which takes several seconds. Is there a way to only update the row being edited by placing the UpdatePanel inside of the ItemTemplate or something like that? I haven't been able to figure this out. I'm sure I've seen an example of something similar to this but can't find it.

Thanks for any help.

You can add UpdatePanel to ItemTemplate/EditTemplate but you will end up with more HTML and javascript on client side.

I would rather focus on finding out why the query takes longer to execute? and fixing it.

Use serverside paging, caching to speed it up. Take a look at ScottGu's Weblog:http://weblogs.asp.net/scottgu/archive/2006/03/22/Efficient-Data-Paging-and-Sorting-with-ASP.NET-2.0-and-SQL-2005.aspx

Wednesday, March 21, 2012

Updatepanel and Literal control

I have a customer search dialog.

The user selects a row from the grid and Literal control is updated with Javascript which should close the dialog should then close and a customer account number field on the parent page should be updated.

This all works until I put the grid inside an Updatepanel - then selecting a row does cause the Literal cojntrol to be updated.

From some testing it seems that the Updatepanel is the cause of the problem - its not letting the grid update the Literal control when it is outside the Updatepanel (And when the Literal control is inside the Updatepanel - updating it doesnt do anything)

I think I can update the Literal control using something like Page.FindControl. However, I have been told that this breaks encapsulation and that I should raise an event from the grid and have the Literal control grab it.

Is raising an event the best solution ?

Updating a Literal with script used to be a great tool for me when I was doing 1.1 development, and posting back all of the time. Setting it with script won't cause the page to execute it unless the page were reloaded.

In this example, you should be fine with removing the UpdatePanel for a dialog box scenario, as a postback will simply cause the dialog window to close.


But I want the UpdatePanel on the dialog box - the user could run a number of searches for a customer before selecting one (Dont think I mentioned that) so I dont want to keep refreshing the whole thing if I can avoid it.
No, you didn't mention that. :)