views:

704

answers:

1

I have created a gridview for populating data, and some user control (TextBox) to update the data and gridview paging. and on the bottom there's a button to update the user input. the table is basically populating names from table and the textbox is for updating that name.

[table]
123456..>>
[button]

when I go to next page, the data i've inserted from previous page are lost.

Is there any way to keep the data while i navigate to next page?

+1  A: 

The paging mechanism of the gridview causes a postback. It sounds like your controls are not saving their information into the viewstate or perhaps on a reload of the page they are resetting to the default values or you haven't saved your information at all on the postback so it is just reloading everything from the original data source.

Check that your viewstate is on for these controls and make sure you aren't resetting values in the code behind such as the page load and if you are needing to save information back to the data source that this is occuring.

klabranche
hmm,..yeah, i've checked that, but seems to have no effect.I think it's the way i do the paging, OnPageIndexChanging i called this method that do something like this, gvName.PageIndex = e.NewPageIndex; DataTable dt = getData(); gvName.DataSource = dt; gvName.DataBind();So, maybe, I repopulate the gridview with the data source everytime i change page, thus the filled textbox lost it's data. I'm not really sure...
Adi
That's exactly what you are doing by calling your GetData and then rebinding it. If you have mod'd the values in any way such as adding a record or changing a field you need to save it first and then rebind.
klabranche
hmm... in other words, do I need to save the values in the textboxes in the memory, and then rebind the page ?
Adi
Yes or commit them back to your data store (DB) and then when you rebind (getData()) they will be bound to the grid.
klabranche