Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);



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...???
Posted

1 solution

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());
}
 
Share this answer
 
Comments
PSK_ 9-Jun-10 6:00am    
Reason for my vote of 1
This doesn’t seems to be a good solution, why to store the data in the hard disk?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900