Multiple directions in DataView.Sort

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alAzif

    Multiple directions in DataView.Sort

    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.S ort = "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.

  • Bob Grommes

    #2
    Re: Multiple directions in DataView.Sort

    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 programmaticall y, 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

    "alAzif" <darkcrawler@gm ail.com> wrote in message
    news:1118105764 .152450.17480@g 47g2000cwa.goog legroups.com...
    [color=blue]
    > 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.S ort = "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.
    >[/color]


    Comment

    • alAzif

      #3
      Re: Multiple directions in DataView.Sort

      Thanx for replying.

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

      T.DefaultView.S ort = "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.S ort = "C1, C2 DESC";

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

      Thanks in advance.
      Jehu.

      Comment

      Working...