G
Guest
Hello, friends,
We have an app in c#.net 2003. There is a dataSet. Its data are populated to
a customized list in a loop (NO data binding, now and future). We need to
modify it so that it can be sorted based on user's selections.
I tried the follows by using DataView, but no luck: It still keeps the
original order.
Any ideas? Any other methods that we can resort records in a dataSet? Thanks !
-----------------------
DataView mDataView = new DataView();
mDataView = mDataSet.Tables[0].DefaultView;
mDataView.Sort = "--user's selections--";
mDataSet.Tables.Clear();
mDataSet = null;
DataSet mDataSet2 = new DataSet();
mDataSet2.Tables.Add(mDataView.Table);
foreach (DataRow dr in mDataSet2.Tables[0].Rows)
{
//check the order
}
We have an app in c#.net 2003. There is a dataSet. Its data are populated to
a customized list in a loop (NO data binding, now and future). We need to
modify it so that it can be sorted based on user's selections.
I tried the follows by using DataView, but no luck: It still keeps the
original order.
Any ideas? Any other methods that we can resort records in a dataSet? Thanks !
-----------------------
DataView mDataView = new DataView();
mDataView = mDataSet.Tables[0].DefaultView;
mDataView.Sort = "--user's selections--";
mDataSet.Tables.Clear();
mDataSet = null;
DataSet mDataSet2 = new DataSet();
mDataSet2.Tables.Add(mDataView.Table);
foreach (DataRow dr in mDataSet2.Tables[0].Rows)
{
//check the order
}