|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sorting a DataTable in a DataSetIs there an easy way to sort a DataTable in a DataSet? I've tried a variety
of ideas, but none of them seems to work. I'm reading in the data from an XML file and I want to sort the list of results, one of the "tables", by date then send the DataSet off for further processing. Any suggestions would be greatly appreciated. TIA Brad Get the DefaultView for the table and then set the Sort property. Something
like: ds.Tables[0].DefaultView.Sort = "DateColumn ASC" /claes Show quoteHide quote "Brad" <brad.markis***@roche.com> wrote in message news:%23CL7$J12GHA.5108@TK2MSFTNGP02.phx.gbl... > Is there an easy way to sort a DataTable in a DataSet? I've tried a > variety of ideas, but none of them seems to work. I'm reading in the data > from an XML file and I want to sort the list of results, one of the > "tables", by date then send the DataSet off for further processing. Any > suggestions would be greatly appreciated. > > TIA > > Brad > Brad,
I don't believe the dataset or datatable has a way to physically re-arrange rows to be in some sorted order, which sounds like what you want. You can, of course, sort a view of the data, such as the defaultview of the datatable. But the rows in the datatable will not be re-arranged. Kerry Moorman Show quoteHide quote "Brad" wrote: > Is there an easy way to sort a DataTable in a DataSet? I've tried a variety > of ideas, but none of them seems to work. I'm reading in the data from an > XML file and I want to sort the list of results, one of the "tables", by > date then send the DataSet off for further processing. Any suggestions > would be greatly appreciated. > > TIA > > Brad > > > Brad,
As Cor pointed out in another newsgroup, the .Net 2.0 version of the dataview has a ToTable method. You can use a dataview to sort the rows of a datatable and then use ToTable to create a new data table with rows that will be in sorted order. Kerry Moorman Show quoteHide quote "Kerry Moorman" wrote: > Brad, > > I don't believe the dataset or datatable has a way to physically re-arrange > rows to be in some sorted order, which sounds like what you want. > > You can, of course, sort a view of the data, such as the defaultview of the > datatable. But the rows in the datatable will not be re-arranged. > > Kerry Moorman > > > "Brad" wrote: > > > Is there an easy way to sort a DataTable in a DataSet? I've tried a variety > > of ideas, but none of them seems to work. I'm reading in the data from an > > XML file and I want to sort the list of results, one of the "tables", by > > date then send the DataSet off for further processing. Any suggestions > > would be greatly appreciated. > > > > TIA > > > > Brad > > > > > >
Excel automation
Determining Sql Column name? IFormatProvider Change look of button (newbie-VB2005 EE) - filenames in ListBox System.Web.Mail problem TreeNode with BOLD font get truncated No "MS .NET Framework 1.1 Wizards" Error BC30002 XXXXX Is not defined Getting information on who is accessing a file |
|||||||||||||||||||||||