I have a problem with preserving or even generating the ViewState of dynamic created BoundColumns. All ViewStates are enabled. History: I need a simple Datagrid (if possible with AutoGenereate Columns) that is editable. The default Datagrid with AutoGen columns
doesn't contain as BoundColumn for a DataColumn of type Guid (UniqueIdentifier). So I decided to generate the BoundColumn on my on: Page_Load() { if (!IsPostBack) { } else { RestoreDataSet from Session } } private void btnSelectData_Click(object sender, System.EventArgs
e) { if (GetGridData()) { BuildGridStructure(); // Add BoundColumns for each DataColumn this.BindGrid(); // this comes after Page_Load: ViewState is/isnt saved? } } Page_PreRender() { SaveData(); // See Page_Load: RestoreDataset } private void grdData_ItemCommand(object
source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (Command == Save) Lookup value for each Column DatagridItem.Cells (Textboxes of BoundColumns) } 1. GET of the page returns the datagrid with my dynamic columns 2. POST: Edit-Command: DataBind()
sets the correct Column to Textboxes 3. POST: Save-Command: Cannot see any Cell in GridLine (grdData.Items[nGridLine].Cells.Count == Number of static Columns!! Even if I rebuilt the dynamic BoundColumns in the datagrid structure in Page_Load (i.e. DataGrid.AddColumn...)
there are no dynamic cells available (apart from the static one for the gridcommands). If I call DataBind() after ReBuilt the GridStructure in Page_Load, I'll loose the GridCommands (that will generated after Page_Load). Is there a method to Reload the Viewstate
after reconstructing the datagrids columns-scheme? Is there another method for a simple gridedit based on a dynamic SQL-Command which will allow UID datatypes?
Filou
Member
29 Points
5 Posts
Datagrid, dynamic BoundColumns loosing ViewState
Aug 05, 2003 01:14 PM|LINK