数据集,gridview,数据表, [英] dataset,gridview,datatable,
本文介绍了数据集,gridview,数据表,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi .....,
hi.....,
DataView myDataView = new DataView();
myDataView = ds1.Tables[0].DefaultView;
if (sortExp != string.Empty)
{
myDataView.Sort = string.Format("{0}{1}",sortExp,sortDir);
}
.....................
grd.DataSource = myDataView;
DataTable dt3 = new DataTable();
dt3 = myDataView.Table.Copy();
ds.Tables.Add(dt3);
我正在做的是在dataview(myDataView)中获取排序的数据.
现在我想将其添加到数据表或数据集中,这将在稍后的代码中使用,但是...它不添加排序的数据... ???
what I''m doing is getting sorted data in dataview (myDataView).!!
now i want to add it in datatable or dataset which will required later in the code but ...its not adding sorted data...???
推荐答案
您排序后可能需要bakup .......
像这样
ds.WriteXml("c://Backup.xml"); ///其中ds是数据集ds = new
DataSet();
当您需要再次将其加载到DataSet中时.....
像这样........
字符串myXMLfile ="C:\\ BackUp.xml";
DataSet ds = new DataSet();
试试
{
ds.ReadXml(myXMLfile);
dataGrid1.DataSource = ds;
}
catch(ex ex例外)
{
MessageBox.Show(ex.ToString());
}
you may take bakup after sorting .......
like this
ds.WriteXml("c://Backup.xml"); /// where ds is DataSet ds=new
DataSet();
when you need again load it in DataSet.....
like this........
string myXMLfile = "C:\\BackUp.xml";
DataSet ds = new DataSet();
try
{
ds.ReadXml(myXMLfile);
dataGrid1.DataSource = ds;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
这篇关于数据集,gridview,数据表,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文