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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    2,049
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,497
  3. William Gower
    Replies:
    2
    Views:
    4,438
    Brian Baker [MVP]
    Jul 26, 2004
  4. Ersin Gençtürk
    Replies:
    1
    Views:
    4,293
    Ersin Gençtürk
    Oct 6, 2004
  5. thomson
    Replies:
    2
    Views:
    15,090
    Eliyahu Goldin
    Jan 19, 2005
  6. DougS

    typed dataset and datagrid

    DougS, Jan 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    457
    DougS
    Jan 7, 2006
  7. Nedu N
    Replies:
    2
    Views:
    428
    Jacob Yang [MSFT]
    Oct 31, 2003
  8. bill yeager

    trying to bind a typed dataset to a datagrid

    bill yeager, Sep 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    250
    bill yeager
    Sep 17, 2004
Loading...