M
mfergu98
Hello: I have several dynamic datagrids being created with editable
templatecolumns. I have a button added at the end of each datagrid
which fires off an update event. The event fires fine, but I can't
seem to be able to retrieve the datagrid. I have tried placing it in
the ViewState, but it tells me that it must be serializable or to use
the TypeConverter. Being relatively new to this, I am not sure exactly
how to go about doing that.
What I want to do is have each datagrid that is created be able to
independently be updated by the buttons associated with them.
In the EventHandler for each button, I've tried:
DataGrid dgr = (DataGrid) Page.FindControl("dgr" + strDataGrid);
and
DataGrid dgr = (DataGrid) ViewState["dgr" + strDataGrid];
but neither finds the datagrid control.
I create each datagrid dynamically based on a selection from a listbox
and add them to the page:
DataGrid dgr = new DataGrid();
TemplateColumn tm9 = new TemplateColumn();
ColumnTemplate ct9 = new ColumnTemplate("txtExtraAdultCharge",
"textbox", "", "", 40);
tm9.HeaderText = "Ext Adt Chg";
tm9.ItemTemplate = ct9;
dgr.Columns.AddAt(7,tm9);
dgr.EnableViewState = true;
this.ViewState.Add("dgr" + i.ToString(), dgr);
Page.Controls[1].Controls.Add(dgr);
Page.Controls[1].Controls.Add(btnUpdate);
I may not even be going down the right path, but any help would be much
appreciated!!
Thank you,
Mark
templatecolumns. I have a button added at the end of each datagrid
which fires off an update event. The event fires fine, but I can't
seem to be able to retrieve the datagrid. I have tried placing it in
the ViewState, but it tells me that it must be serializable or to use
the TypeConverter. Being relatively new to this, I am not sure exactly
how to go about doing that.
What I want to do is have each datagrid that is created be able to
independently be updated by the buttons associated with them.
In the EventHandler for each button, I've tried:
DataGrid dgr = (DataGrid) Page.FindControl("dgr" + strDataGrid);
and
DataGrid dgr = (DataGrid) ViewState["dgr" + strDataGrid];
but neither finds the datagrid control.
I create each datagrid dynamically based on a selection from a listbox
and add them to the page:
DataGrid dgr = new DataGrid();
TemplateColumn tm9 = new TemplateColumn();
ColumnTemplate ct9 = new ColumnTemplate("txtExtraAdultCharge",
"textbox", "", "", 40);
tm9.HeaderText = "Ext Adt Chg";
tm9.ItemTemplate = ct9;
dgr.Columns.AddAt(7,tm9);
dgr.EnableViewState = true;
this.ViewState.Add("dgr" + i.ToString(), dgr);
Page.Controls[1].Controls.Add(dgr);
Page.Controls[1].Controls.Add(btnUpdate);
I may not even be going down the right path, but any help would be much
appreciated!!
Thank you,
Mark