In this thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/accessing-the-column-collection-for-autogenerated-columns.aspx
I mentioned how I handled reordering columns (often to restore a stored order) in the PreRender when using RadGrid in RadControls for ASP.Net and more recently in RadControls for ASP.Net AJAX. At the time of that thread, I hadn't quite gotten it working in the AJAX version, but subsequently seemed to get it to work.
However, i am now hitting a problem that I haven't quite put my finger on. My code in PreRender keeps track of whether or not it actually needed to change the column order (as it loops through the columns in RenderColumns if any needs to be reordered it sets a flag that it did so.) If the flag gets set, then it does a Rebind of the grid (since otherwise the new order doesn't match the data).
Now I am finding that when I do so, on a subsequent refresh of the page, I get the dreaded:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.
error. This ONLY occurs if I reordered and did a Rebind in PreRend. I'm surmising that there is something in the viewstate loading for RadGrid that expects the column order (and therefore types of the columns) or something related (filter row maybe?) not to have changed as late as the preRender (maybe some other structure in the RadGrid that has viewstate saved as well that could be out of sync if i reorder and rebind in PreRender?)
Anyway, I am still debugging on this, but any sugestions appreciated. The previously suggested approach of turning off viewstate for this grid is, however, not an acceptable soluytion, so suggesting that doesn't help. There are many aspects of the grid state that viewstate retains that we cannot sacrifice in terms of end user functionality, nor do we want to reimplement all the viewstate stuff for the grid without viewstate. The core problem i need guidance on is how, with viewstate enabled, I can reorder and rebind my grid safely.
Thanks,
-Ed
http://www.telerik.com/community/forums/aspnet-ajax/grid/accessing-the-column-collection-for-autogenerated-columns.aspx
I mentioned how I handled reordering columns (often to restore a stored order) in the PreRender when using RadGrid in RadControls for ASP.Net and more recently in RadControls for ASP.Net AJAX. At the time of that thread, I hadn't quite gotten it working in the AJAX version, but subsequently seemed to get it to work.
However, i am now hitting a problem that I haven't quite put my finger on. My code in PreRender keeps track of whether or not it actually needed to change the column order (as it loops through the columns in RenderColumns if any needs to be reordered it sets a flag that it did so.) If the flag gets set, then it does a Rebind of the grid (since otherwise the new order doesn't match the data).
Now I am finding that when I do so, on a subsequent refresh of the page, I get the dreaded:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.
error. This ONLY occurs if I reordered and did a Rebind in PreRend. I'm surmising that there is something in the viewstate loading for RadGrid that expects the column order (and therefore types of the columns) or something related (filter row maybe?) not to have changed as late as the preRender (maybe some other structure in the RadGrid that has viewstate saved as well that could be out of sync if i reorder and rebind in PreRender?)
Anyway, I am still debugging on this, but any sugestions appreciated. The previously suggested approach of turning off viewstate for this grid is, however, not an acceptable soluytion, so suggesting that doesn't help. There are many aspects of the grid state that viewstate retains that we cannot sacrifice in terms of end user functionality, nor do we want to reimplement all the viewstate stuff for the grid without viewstate. The core problem i need guidance on is how, with viewstate enabled, I can reorder and rebind my grid safely.
Thanks,
-Ed