D
deko
I have a WinForms app that builds a DataSet from an XML file. The DataSet
is wrapped in a DataView and bound to various controls through which users
will make changes to the data, and when the "Save and Close" button on my
form is clicked, the changes persist back to XML using XmlDataDocument.
My question is this: Should I update the DataView or the DataSet?
An example of updating the DataSet might look like this:
public static void newLst(DataSet xdd)
{
DataView dv = null;
dv = new DataView (
xdd.Tables["Configuration"],
"ProjectName = 'UnassignedConfiguration'",
"ConfigurationName",
DataViewRowState.CurrentRows
);
//dv.AllowEdit = true;
//dv.AllowNew = true;
//dv.AllowDelete = true;
//why would I want to use the above methods rather than updating the DataSet
directly?
}
An example of updating the DataSet might look like this:
public static void chgNam
(
DataSet xdd,
string oldNam,
string newNam,
string tblNam
)
{
DataTable dt = xdd.Tables[tblNam];
DataRow dr = dt.Rows.Find(oldNam);
dr[tblNam + "Name"] = newNam;
}
Suggestions or comments welcome!
Thanks in advance.
is wrapped in a DataView and bound to various controls through which users
will make changes to the data, and when the "Save and Close" button on my
form is clicked, the changes persist back to XML using XmlDataDocument.
My question is this: Should I update the DataView or the DataSet?
An example of updating the DataSet might look like this:
public static void newLst(DataSet xdd)
{
DataView dv = null;
dv = new DataView (
xdd.Tables["Configuration"],
"ProjectName = 'UnassignedConfiguration'",
"ConfigurationName",
DataViewRowState.CurrentRows
);
//dv.AllowEdit = true;
//dv.AllowNew = true;
//dv.AllowDelete = true;
//why would I want to use the above methods rather than updating the DataSet
directly?
}
An example of updating the DataSet might look like this:
public static void chgNam
(
DataSet xdd,
string oldNam,
string newNam,
string tblNam
)
{
DataTable dt = xdd.Tables[tblNam];
DataRow dr = dt.Rows.Find(oldNam);
dr[tblNam + "Name"] = newNam;
}
Suggestions or comments welcome!
Thanks in advance.