I have two datagrids on a page. On the update event of the first I take
some of the selected data, create a dataset and add it and then bind it to
the second datagrid. If I hit update several times it adds a new row to the
dataset and binds accordingly to the second datagrid. When I press cancel
and edit again the next update wipes the dataset that Iam binding to scond
datagrid. It is as if the cancel sets the dataset to nothing.
I am saving the dataset to a session on page unload and loading it in again
on the update command (or creating it for the first click on update) This is
code I use in the update event of the first datagrid. I have a feeling this
is something obvious but I am quite new to .net.
If IsNothing(Session("editteddataset")) Then
editteddataset = New DataSet()
editteddataset.ReadXmlSchema("C:\Inetpub\wwwroot\x mlxconfig\dseditted2.xsd")
Else
editteddataset = Session("editteddataset")
End If
Dim dsItem As DataRow
Dim dsTable As DataTable
dsTable = editteddataset.Tables("TABLEINFO")
dsItem = editteddataset.Tables("TABLEINFO").NewRow
Dim getcontroltype As DropDownList
getcontroltype = CType(e.Item.FindControl("controltype"), DropDownList)
dsItem("CONTROLTYPE") = getcontroltype.SelectedItem
dsTable.Rows.Add(dsItem)
'ds.WriteXml("c:\xmlconfig")
DataGrid2.Visible = True
DataGrid2.DataSource = editteddataset
DataGrid2.DataBind()