Re: How to resort records in a dataSet?

Tech-Archive recommends: Fix windows errors by optimizing your registry



The DataView is the correct path. Let's see your code.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Andrew" <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A315398B-FE8E-41C0-943B-01608EA9F883@xxxxxxxxxxxxxxxx
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
}




.



Relevant Pages

  • Re: dataview sort problem
    ... DataView completely. ... foreach (DataRow _Project in dvProject.Table.Rows) ... Instead of using foreach, use a for loop since the order "matters" to you ... original order. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: dataview sort problem
    ... DataView completely. ... foreach (DataRow _Project in dvProject.Table.Rows) ... Instead of using foreach, use a for loop since the order "matters" to you ... original order. ...
    (microsoft.public.dotnet.framework.adonet)