typed DataSet-bound DataGrid sorting

Discussion in 'ASP .Net Web Controls' started by Whugster, Jun 29, 2004.

  1. Whugster

    Whugster Guest

    Hi. I have a DataGrid bound to a typed DataSet and I just couldn't figure
    out how to sort the damn thing. I tried setting the Sort property of the
    DataTable.DefaultView and the Attributes["SortExpr"] of the DataGrid but I
    think the order of events matter. Here's a breakdown of events:

    1. Page_Load:
    - call my method LoadGrid( )
    - call Page.DataBind( )

    2. my method LoadGrid:
    - set mytypeddataset = MethodThatGetsFilledDataSet( )

    3. SortCommand grid event handler:
    - mytypeddataset.Tables["MyTable"].DefaultView.Sort = "somesortstring"
     
    Whugster, Jun 29, 2004
    #1
    1. Advertising

  2. Whugster

    MattC Guest

    I'm pretty sure you want binding to be the last thing that is done, i.e,
    have your dataset sorted then bind it to the grid for displaying.

    MattC
    "Whugster" <> wrote in message
    news:...
    > Hi. I have a DataGrid bound to a typed DataSet and I just couldn't figure
    > out how to sort the damn thing. I tried setting the Sort property of the
    > DataTable.DefaultView and the Attributes["SortExpr"] of the DataGrid but I
    > think the order of events matter. Here's a breakdown of events:
    >
    > 1. Page_Load:
    > - call my method LoadGrid( )
    > - call Page.DataBind( )
    >
    > 2. my method LoadGrid:
    > - set mytypeddataset = MethodThatGetsFilledDataSet( )
    >
    > 3. SortCommand grid event handler:
    > - mytypeddataset.Tables["MyTable"].DefaultView.Sort = "somesortstring"
    >
    >
    >
     
    MattC, Jun 29, 2004
    #2
    1. Advertising

  3. Whugster

    Whugster Guest

    Yea that seems to be the problem because binding to a typed dataset happens
    underneath. I just dragged and dropped a DataView object to the page and
    bind from that object. The solved it. Thanks.


    "MattC" <> wrote in message
    news:...
    > I'm pretty sure you want binding to be the last thing that is done, i.e,
    > have your dataset sorted then bind it to the grid for displaying.
    >
    > MattC
    > "Whugster" <> wrote in message
    > news:...
    >> Hi. I have a DataGrid bound to a typed DataSet and I just couldn't figure
    >> out how to sort the damn thing. I tried setting the Sort property of the
    >> DataTable.DefaultView and the Attributes["SortExpr"] of the DataGrid but
    >> I
    >> think the order of events matter. Here's a breakdown of events:
    >>
    >> 1. Page_Load:
    >> - call my method LoadGrid( )
    >> - call Page.DataBind( )
    >>
    >> 2. my method LoadGrid:
    >> - set mytypeddataset = MethodThatGetsFilledDataSet( )
    >>
    >> 3. SortCommand grid event handler:
    >> - mytypeddataset.Tables["MyTable"].DefaultView.Sort =
    >> "somesortstring"
    >>
    >>
    >>

    >
    >
     
    Whugster, Jun 29, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,802
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,160
  3. William Gower
    Replies:
    2
    Views:
    4,144
    Brian Baker [MVP]
    Jul 26, 2004
  4. thomson
    Replies:
    2
    Views:
    14,833
    Eliyahu Goldin
    Jan 19, 2005
  5. Nedu N
    Replies:
    2
    Views:
    223
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page