Question

I have a gridview control (among other things) inside an update panel. Part of the data on the gridview row is loaded asynchronously through an Ajax request. When a button in the gridview is clicked the gridview's RowCommand processes some code on the server side. The data loaded through Ajax is lost when the page is posted back.

I have added code to request the data through Ajax after each postback from the update panel. However this takes time and I would like to somehow store or cache the data so that it doesn't need to request the data after each partial postback.

The returned result from the Ajax request returns some text with html formatting. This is added to the table row through JQuery.

Is there some way to cache this info on the client side so that it doesn't require secondary Ajax requests after each partial postback? I tried storing the data in a hidden field but when the value of the hidden field contains html markup it broke the updatepanel.

Was it helpful?

Solution

It sounds like the GridView is getting loaded from ViewState on the UpdatePanel postback and that's why you're losing the Ajax changes. If your Ajax call is changing the underlying data, can you reload your data from the underlying source after your UpdatePanel post?

If not, I agree with TheGeek. I suspect you'll have better results going with a consistent platform - either straight JavaScript for both, or UpdatePanel for both.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top