I have a user control which contains a WHDG. This grid has a few basic properties set in the .aspx file. All of the columns, behaviors, editorproviders, etc... are added in the code behind.
Things work great the first time the page loads, however on a postback, such as a Save button click, the grid gets reloaded but all of the editors seem to get out of whack.
One post recommends applying the behaviors to the Grid.GridView, however this doesn't seem to work. When I try this, none of the EditingBehaviors appear to be getting created, even on the first page load.
Another post suggests that Editors/Behaviors added at runtime need to be reinstaniated on each postback. Following this approach doesn't seem to make any difference.
When I view source on the first grid and compare against the same grid after postback, everything seems to be there. However there is additional HTML that appears to be setting my editors to hidden. Which means something must be triggering the HierarchicalGridRender to emit this additional HTML. Either I am missing a property or something is null causing the HTML to get triggered during rendering.
Hi
Is this issue fixed for you? can you help me to retain the editor control values during postback?
Attached source code doesn't have the DropdownEditor provider code.
Thanks
Sam
Here is a sample, this particular sample has a user control, but you can remove that and just do everything directly in page as needed. Also note the grid.databind() that occurs between creating the columns and creating the behaviors. I never had a chance to trace through the code to see why this step needed to be there, but if it isn't things start to go bad quickly.
Good Luck!
I went around and around with the dev support team on this, finally ended up with an approach that seems to work.
My approach was all handled on the server side though, not on the client side. I would recommend doing it in the code behind versus on the client side via javascript, although I am sure it can be done in a similar fashion.
The key comes down to defining the editorproviders at the right point in the page life cycle. And then on every subsequent postback, re-initiliazing the editor for each editor provider, i.e.
Setup columns, behaviors, and databind your grid in the PreInit Method of the page
And then on Page_Load
For each editor provider
Get editor (editorprovider.getEditor())
Cast the editor to the appropriate editor type (WebTextEdit, WebDropDown, etc....)
For WebDropDowns be sure to rebind the datasource
That should get you started, becareful it seems very fragile, it is easy to get the viewstate out of whack if you are doing things at the wrong spot in the page lifecycle.
I'll try to attach a sample code.
Hello,
I have the same problem, after a postback i lost my ProviderEditor, checking the client object i found that the ColumnSettings of my grid disappear. Any one have the solution for this? are there any way to create a ColumnSettings on client side?
I am working on a project where we are encountering similar challenges with editor providers losing state during AJAX postback scenarios. When I attempt to restore behaviors, editor providers, etc on subsequent postbacks I have run into a variety of errors that I suspect relate to the points in the Page Life cycle where I attempt to synch up these details. At times I lose viewstate of the original data in the grid, at other I get errors that items are already defined.
Has anyone found any posted examples for recommended practices how to implement this correctly?