I have a gridview control on the page. when the page is loaded for the first time i am binding the data to the grid. But on the client side user can copy a row and add below in the grid. So iam doing it using jquery $(CpRow).clone(true).insertAfter(CpRow). But when the page is postback the clientside added row is lost due to viewstate.
how can i update the gridview view state so that the row is not lost in further postbacks.
Thanks 开发者_StackOverflowin advance...
The long and short of it is that there is no simple way to do this. I'm surprised you are even able to postback without getting an invalid viewstate error given that the controls collection (via Request.Form) won't match the viewstate.
If you're not getting invalid viewstate issues, you may be able to store the IDs of the rows you have cloned in a hidden field and do some processing of these IDs on Postback to re-add the cloned rows on the server. This will ensure the cloned rows have their values stored in viewstate correctly.
Hope this helps, apologies if it's a vague answer - like I said, there are no simple solutions with regard to this problem.
The view state has to be created on the server side. To change the grid and have it survive the post back, you have to change the grid through some sort of an asp.net postback/asp.net ajax post.
The problem is solved, i used hidden variables to store the cloned rows at the server and once the postback happens i am re binding the grid with new rows added.
Thanks 4 the answers..
精彩评论