I search a way to add an attribute to an asp.net gridview.
the value of the attribute will change on page change (PageIndexChanging) and sort event (Sorting).
the attribute will be used on javascript.
Before I had an hiddenfield, but the post back doesn’t change the value of the hiddenfield.
I try
mygrid.Rows(0).Cells(0).Attributes.Add("myAttribute", "test")
If you had an idea or need more details for understanding.
That should work to add the attribute to the row. Attributes will not be available on postback though, and will not save on postback. The only way to save across postbacks is hidden field. An
<asp:HiddenField>control will save it’s value on postback; you would have to explicitly change it to a new value. However, it will at least get the value to the backend server when the page posts back.