I have a gridview control that extends the default gridview. I have added an attribute called “hiddenSelectedValues” to to the gridview during the “PreRender” event and I have a private variable that points to the value of that attribute.
I have some javascript code that modifies the value of this attribute based on the user checking or unchecking checkboxes in the grid. I have confirmed that the javascript is indeed modifying the value of the “hiddenSelectedValues” attribute by using Firebug to see the change as it happens.
However, once a postback occurs, the grid looses the updated value of this attribute and I am unable to reference get the updated value on the server side.
How do I keep the value of an attribute changed by javascript on postback?
You need to use a hidden filed. That’s because no attributes are passed on the request back to the web server.
Added in reply to comment.
You can accomplish this using hidden fields INSIDE the row without problems. Simply give the hidden fields the same
NAMEattribute and useRequest["<name>"].Split(",")to retrieve an array of values on the post-back.