Multiple directions in DataView.Sort

A

alAzif

Hi everyone.

If I have a table T with columns C1 and C2, I would like to know if the
following is possible:

T.DefaultView.Sort = "C1 ASC, C2 DESC";

If this is not so, I would really appreciate other options you might
think of.
Table T is not populated from a database. It is created and filled
dynamically, so receiving the data pre-sorted is not an option.

Thanks in advance.

Jehu.
 
B

Bob Grommes

Jehu,

All you have to do is look up DataView.Sort in the help and you'll find this
about what goes in the Sort property:

"A string containing the column name followed by "ASC" (ascending) or "DESC"
(descending). Columns are sorted ascending by default. Multiple columns can
be separated by commas."
You could have tested to see if this worked in about 3 minutes, too.

The source of the data (whether it comes from a back end database or is
inserted into the DataTable programmatically, etc) has no bearing on whether
or not this works, if that's what you're wondering. You can think of a
DataSet as a lightweight client-side in-memory database, really.

--Bob
 
A

alAzif

Thanx for replying.

I have, in fact, tested it.
Using my previous example:

T.DefaultView.Sort = "C1 ASC, C2 DESC";

I found it only respects the direction given to C1 (ASC), the other one
is completely ignored when browsing the results.

I have looked at several sources on the internet, some say you can give
multiple directions in the Sort expression and others, like MSDN, only
provide examples where a single direction is used, and is specified at
the end of the expression:

T.DefaultView.Sort = "C1, C2 DESC";

Have you tried using multiple directions in the DataView.Sort property?

Thanks in advance.
Jehu.
 

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