Datagrid sorting does not work

Discussion in 'ASP .Net Datagrid Control' started by Veeves, Mar 18, 2005.

  1. Veeves

    Veeves Guest

    I have added sorting to my datagrid. I added the event handler

    Private Sub dgrItems_SortCommand(ByVal source As Object, _
    ByVal e As
    System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
    dgrItems.SortCommand
    processSortIt(e.SortExpression)
    End Sub

    I also have an Private Sub dgrItems_ItemCommand event handler on this
    web page.

    When I click on one of the links in the header that should fire the
    SortCommand event, the ItemCommand fires instead.

    Anyone know a way to get around this?


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Veeves, Mar 18, 2005
    #1
    1. Advertising

  2. Veeves

    Elton Wang Guest

    It's true that ItemCommand fires first then SortCommand
    fires.

    In ItemCommand event, you can

    If e.CommandName.Equals("Sort") Then
    Return; ' bypass the event
    End If

    HTH

    Elton Wang
    elton_hotmail.com

    >-----Original Message-----
    >
    >
    >I have added sorting to my datagrid. I added the event

    handler
    >
    > Private Sub dgrItems_SortCommand(ByVal source As

    Object, _
    > ByVal e As
    >System.Web.UI.WebControls.DataGridSortCommandEventArgs)

    Handles
    >dgrItems.SortCommand
    > processSortIt(e.SortExpression)
    > End Sub
    >
    >I also have an Private Sub dgrItems_ItemCommand event

    handler on this
    >web page.
    >
    >When I click on one of the links in the header that

    should fire the
    >SortCommand event, the ItemCommand fires instead.
    >
    >Anyone know a way to get around this?
    >
    >
    >*** Sent via Developersdex http://www.developersdex.com

    ***
    >Don't just participate in USENET...get rewarded for it!
    >.
    >
     
    Elton Wang, Mar 18, 2005
    #2
    1. Advertising

  3. Veeves

    Veeves Guest

    Thanks. This was a simple solution.

    Veeves


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Veeves, Mar 18, 2005
    #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. =?Utf-8?B?U2FtZWVrc2hh?=

    DataGrid Sorting does not work

    =?Utf-8?B?U2FtZWVrc2hh?=, Sep 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,310
    =?Utf-8?B?U2FtZWVrc2hh?=
    Sep 24, 2004
  2. Sinan
    Replies:
    0
    Views:
    476
    Sinan
    Jan 28, 2005
  3. TB
    Replies:
    2
    Views:
    3,789
  4. Replies:
    0
    Views:
    638
  5. Phi!
    Replies:
    1
    Views:
    209
Loading...

Share This Page