Can't get this grid to sort no matter what - going crazy.

Discussion in 'ASP .Net Datagrid Control' started by Dan, Jan 8, 2004.

  1. Dan

    Dan Guest

    Seems like i've tried every example in the newsgroups and in
    referenced articles but I just can't get this grid to sort, am I
    missing something obvious?

    View State = True
    Allow Sorting = True
    Sort Expressions in Property Builder set to Column Names

    Code for Sort Command:

    Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e
    As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
    DataGrid1.SortCommand

    Dim dv As New DataView(GridSet1.Tables("driverstatus_a"))

    dv.Sort = e.SortExpression

    DataGrid1.DataSource = dv
    DataGrid1.DataBind()


    End Sub

    Any help is appreciated
    Dan
    Dan, Jan 8, 2004
    #1
    1. Advertising

  2. Dan

    Alvin Bruney Guest

    that code should work, what problems are you seeing?

    --
    Regards,
    Alvin Bruney
    Got tidbits? Get it here...
    http://tinyurl.com/2bz4t
    "Dan" <> wrote in message
    news:...
    > Seems like i've tried every example in the newsgroups and in
    > referenced articles but I just can't get this grid to sort, am I
    > missing something obvious?
    >
    > View State = True
    > Allow Sorting = True
    > Sort Expressions in Property Builder set to Column Names
    >
    > Code for Sort Command:
    >
    > Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e
    > As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
    > DataGrid1.SortCommand
    >
    > Dim dv As New DataView(GridSet1.Tables("driverstatus_a"))
    >
    > dv.Sort = e.SortExpression
    >
    > DataGrid1.DataSource = dv
    > DataGrid1.DataBind()
    >
    >
    > End Sub
    >
    > Any help is appreciated
    > Dan
    >
    Alvin Bruney, Jan 8, 2004
    #2
    1. Advertising

  3. Dan

    Dan Guest

    "Alvin Bruney" <vapor at steaming post office> wrote in message news:<>...
    > that code should work, what problems are you seeing?
    >
    > --
    > Regards,
    > Alvin Bruney
    > Got tidbits? Get it here...
    > http://tinyurl.com/2bz4t
    > "Dan" <> wrote in message
    > news:...
    > > Seems like i've tried every example in the newsgroups and in
    > > referenced articles but I just can't get this grid to sort, am I
    > > missing something obvious?
    > >
    > > View State = True
    > > Allow Sorting = True
    > > Sort Expressions in Property Builder set to Column Names
    > >
    > > Code for Sort Command:
    > >
    > > Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e
    > > As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
    > > DataGrid1.SortCommand
    > >
    > > Dim dv As New DataView(GridSet1.Tables("driverstatus_a"))
    > >
    > > dv.Sort = e.SortExpression
    > >
    > > DataGrid1.DataSource = dv
    > > DataGrid1.DataBind()
    > >
    > >
    > > End Sub
    > >
    > > Any help is appreciated
    > > Dan
    > >


    Found the problem, courtesy of DataGrid Girl:

    "In your ASPX, in the <asp:Datagrid declaration you've
    got this:

    DataSource="<%# GridSet1 %>"

    Any Datagrid properties set declaratively will
    override the ones you set in code, so when you set the DataSource to
    the filtered DataView, it's not ever taking effect. Take this
    property out of the declaration, and in your Page_Load, add a line to
    set the DataSource to your GridSet1."

    After I eliminated this code in the aspx, it worked fine. This is a
    'gotcha', because VStudio automatically put this line in the aspx file
    when it built the page - and I was on a wild goose chase thinking the
    problem had to be in the vb code....

    Thanks to all. Thank you datagrid girl.
    Dan, Jan 8, 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. Navin
    Replies:
    3
    Views:
    640
    Navin
    Jul 28, 2003
  2. Jay Douglas
    Replies:
    0
    Views:
    398
    Jay Douglas
    Aug 28, 2003
  3. Larry Tate

    getting confused and going crazy

    Larry Tate, Dec 21, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    487
    Larry Tate
    Dec 21, 2003
  4. andresm

    i am going to get crazy!!!

    andresm, Sep 15, 2004, in forum: Python
    Replies:
    16
    Views:
    637
    Paul McNett
    Sep 16, 2004
  5. giff
    Replies:
    17
    Views:
    1,615
    benben
    Feb 27, 2006
Loading...

Share This Page