Applying custom sort order to typed dataset

E

Emma Burrows

I have created a typed dataset in .Net 2.0 based on an Access database, and
set up various methods to retrieve specific data from the tables, etc (great
fun). However, I need to implement a custom sort order on a text column. I
know how to implement this in an IComparer and apply it to a custom
collection or an array, but I don't see an easy way to tie this up with my
strongly typed dataset (short of adding the extra step of feeding it into a
custom collection or an array...).

I would welcome any existing code examples of how to do this, or at least
suggestions that might point me in the right direction. Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Emma,

Why not use a DataView on the typed DataTable? In the end, it is a
DataTable, and a DataView is meant to provide this kind of "view" on the
data.

Hope this helps.
 
E

Emma Burrows

Nicholas Paldino said:
Why not use a DataView on the typed DataTable?

Thanks for the suggestion. I did have a look into DataView, but it only
seems to allow you to apply a sort order based on a basic SQL statement (eg:
"Title, Author DESC"). My problem is that I need the rows to be sorted on
far more complex criteria than that.

To be specific, I'm sorting book titles by their first significant word; on
the current version of my website, I use XSL to do this (see
http://www.codeproject.com/soap/XSLSorting.asp for details of the sort order
I'm trying to achieve and how I did this in XSL). I'm converting the website
to use .Net features but this is one thing I haven't managed to work out yet
(except using an IComparable object, but I don't see how to apply that to my
DataSet). So suggestions are still welcome. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top