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 in 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.