Hello,
I want to change the column order in code (in Page_Load).
i write this code:
GridColumn gc1 = MyGrid.Columns.FindByDataField("ID");
GridColumn gc2 = MyGrid.Columns.FindByDataField("NAME");
MyGrid.Columns.Remove(gc1);
MyGrid.Columns.Remove(gc2);
MyGrid.Columns.AddAt(0,gc2);
MyGrid.Columns.AddAt(0,gc1);
with this code i took "ID" column and "NAME" column and put them right in the start.
When the page is loaded in the first time, everything look good, the "ID" is at the start and the "Name" is right after.
when i click on the grid or make any postback to the server i get this error:
"Sys.WebForms.PageRequestManagerServerException: Failed to load viewstate. the control tree into which viewsate being loaded must match the control tree that was used to save viewstate during the previous request. for example, when adding controls dynamically the controls added during a post back must match the type and position of the control added during the initial request
Can you please help me with changed index spot during page_load event?
I have no idea what to do with this error.
Yael.
I want to change the column order in code (in Page_Load).
i write this code:
GridColumn gc1 = MyGrid.Columns.FindByDataField("ID");
GridColumn gc2 = MyGrid.Columns.FindByDataField("NAME");
MyGrid.Columns.Remove(gc1);
MyGrid.Columns.Remove(gc2);
MyGrid.Columns.AddAt(0,gc2);
MyGrid.Columns.AddAt(0,gc1);
with this code i took "ID" column and "NAME" column and put them right in the start.
When the page is loaded in the first time, everything look good, the "ID" is at the start and the "Name" is right after.
when i click on the grid or make any postback to the server i get this error:
"Sys.WebForms.PageRequestManagerServerException: Failed to load viewstate. the control tree into which viewsate being loaded must match the control tree that was used to save viewstate during the previous request. for example, when adding controls dynamically the controls added during a post back must match the type and position of the control added during the initial request
Can you please help me with changed index spot during page_load event?
I have no idea what to do with this error.
Yael.