且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数据集和数据表

更新时间:2023-12-01 10:10:04

请尝试以下代码.
Try as below code.
DataSet mydata = new DataSet("mydata");
mydata.ReadXml("YourXmlFilePath");

DataTable firstDataTable = new DataTable();
DataTable secondDataTable = new DataTable();

if (mydata.Tables.Count > 0)
{
  firstDataTable = mydata.Tables[0].Copy();
  secondDataTable = mydata.Tables[0].Copy();

  //Remove columns from the first DataTable which you want to remove.
  firstDataTable.Columns.Remove("ColumnNameToRemove1");

  //Remove columns from the second DataTable which you want to remove.
  secondDataTable.Columns.Remove("ColumnNameToRemove2");
}


您可以手动"读取XML文件,并将每个项目转移到适当的数据集中,然后将其绑定到相关的数据网格.或者,您可以采用上面创建的数据集,然后将数据列中的数据手动复制到其他数据集中.无论哪种情况,都需要一些工作.
You could read the XML file ''manually'' and transfer each item into the appropriate dataset which you can then bind to the relevant datagrid. Alternatively you could take your dataset as created above and manually copy columns of data from that into other datasets. In either case it requires a bit of work.