DataGrid Not Sorting

Discussion in 'ASP .Net Datagrid Control' started by Michael Caruso, Oct 6, 2005.

  1. My web datagrid isn't sorting at all. I have it wired up to a handler, and I
    know the handler is working (being called), but no sorting. The page just
    posts back with the same data. I hhave verified that the SortExpression
    values are the column names. I used the VS IDE to create a datasource ( a
    DataSet), defined a table and columns, then used the datagrid Propery Builder
    to tie eveything together. The table gets populated with data correctly, I
    just can't get it to sort.

    Any help would be greatly appreciated.
     
    Michael Caruso, Oct 6, 2005
    #1
    1. Advertising

  2. Michael Caruso

    Brock Allen Guest

    If you're using a DataGrid then you have to do the sorting yourself in the
    Sort event and rebind the DataGrid. It doesn't sort by itself, unfortunately.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > My web datagrid isn't sorting at all. I have it wired up to a
    > handler, and I know the handler is working (being called), but no
    > sorting. The page just posts back with the same data. I hhave
    > verified that the SortExpression values are the column names. I used
    > the VS IDE to create a datasource ( a DataSet), defined a table and
    > columns, then used the datagrid Propery Builder to tie eveything
    > together. The table gets populated with data correctly, I just can't
    > get it to sort.
    >
    > Any help would be greatly appreciated.
    >
     
    Brock Allen, Oct 6, 2005
    #2
    1. Advertising

  3. Yep, I'm doing that. The OnSortCommand handler retrieves a dataset from a
    session variable (created when the page loaded), creates a dataview, then
    sorts on the SortExpression from the column clicked, assigns the DataSource
    and then rebinds the grid. Only it doesn't work. It acts like DataView.Sort
    doesn't work. I tried setting the intial sort expression to a different
    column when the page loads, that doesn't work either.

    "Brock Allen" wrote:

    > If you're using a DataGrid then you have to do the sorting yourself in the
    > Sort event and rebind the DataGrid. It doesn't sort by itself, unfortunately.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    > > My web datagrid isn't sorting at all. I have it wired up to a
    > > handler, and I know the handler is working (being called), but no
    > > sorting. The page just posts back with the same data. I hhave
    > > verified that the SortExpression values are the column names. I used
    > > the VS IDE to create a datasource ( a DataSet), defined a table and
    > > columns, then used the datagrid Propery Builder to tie eveything
    > > together. The table gets populated with data correctly, I just can't
    > > get it to sort.
    > >
    > > Any help would be greatly appreciated.
    > >

    >
    >
    >
     
    Michael Caruso, Oct 7, 2005
    #3
  4. Michael Caruso

    Brock Allen Guest

    Hmm, not sure then. Sounds like you're doing all the right things. I'd suggest
    making a new project with one page with the one grid and try to see if you
    can make it work outside of everything else -- more of a sanity check. If
    you can get that working then it's not the code you have for the grid, it's
    likley code elsewhere in the page that's thwarting the sort.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > Yep, I'm doing that. The OnSortCommand handler retrieves a dataset
    > from a session variable (created when the page loaded), creates a
    > dataview, then sorts on the SortExpression from the column clicked,
    > assigns the DataSource and then rebinds the grid. Only it doesn't
    > work. It acts like DataView.Sort doesn't work. I tried setting the
    > intial sort expression to a different column when the page loads, that
    > doesn't work either.
    >
    > "Brock Allen" wrote:
    >
    >> If you're using a DataGrid then you have to do the sorting yourself
    >> in the Sort event and rebind the DataGrid. It doesn't sort by itself,
    >> unfortunately.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> My web datagrid isn't sorting at all. I have it wired up to a
    >>> handler, and I know the handler is working (being called), but no
    >>> sorting. The page just posts back with the same data. I hhave
    >>> verified that the SortExpression values are the column names. I
    >>> used the VS IDE to create a datasource ( a DataSet), defined a table
    >>> and columns, then used the datagrid Propery Builder to tie eveything
    >>> together. The table gets populated with data correctly, I just
    >>> can't get it to sort.
    >>>
    >>> Any help would be greatly appreciated.
    >>>
     
    Brock Allen, Oct 7, 2005
    #4
  5. I'd considered doing that, but what I do if it does work? What kinds of
    things would prevent the sort from working? I've never tried using the sort
    feature on a datagrid before so this is new territory. I've used dataviews
    before, and implemented sorting, but I've never used the datagrid component
    before like this. Could there be something in the way the DataSource is
    defined in the page that affects the sorting?



    "Brock Allen" wrote:

    > Hmm, not sure then. Sounds like you're doing all the right things. I'd suggest
    > making a new project with one page with the one grid and try to see if you
    > can make it work outside of everything else -- more of a sanity check. If
    > you can get that working then it's not the code you have for the grid, it's
    > likley code elsewhere in the page that's thwarting the sort.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    > > Yep, I'm doing that. The OnSortCommand handler retrieves a dataset
    > > from a session variable (created when the page loaded), creates a
    > > dataview, then sorts on the SortExpression from the column clicked,
    > > assigns the DataSource and then rebinds the grid. Only it doesn't
    > > work. It acts like DataView.Sort doesn't work. I tried setting the
    > > intial sort expression to a different column when the page loads, that
    > > doesn't work either.
    > >
    > > "Brock Allen" wrote:
    > >
    > >> If you're using a DataGrid then you have to do the sorting yourself
    > >> in the Sort event and rebind the DataGrid. It doesn't sort by itself,
    > >> unfortunately.
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> http://staff.develop.com/ballen
    > >>> My web datagrid isn't sorting at all. I have it wired up to a
    > >>> handler, and I know the handler is working (being called), but no
    > >>> sorting. The page just posts back with the same data. I hhave
    > >>> verified that the SortExpression values are the column names. I
    > >>> used the VS IDE to create a datasource ( a DataSet), defined a table
    > >>> and columns, then used the datagrid Propery Builder to tie eveything
    > >>> together. The table gets populated with data correctly, I just
    > >>> can't get it to sort.
    > >>>
    > >>> Any help would be greatly appreciated.
    > >>>

    >
    >
    >
     
    Michael Caruso, Oct 7, 2005
    #5
  6. Michael Caruso

    Brock Allen Guest

    Well, try it in the standalong page and if you can't get that to work send
    me an email and I can give you a working sample.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > I'd considered doing that, but what I do if it does work? What kinds
    > of things would prevent the sort from working? I've never tried using
    > the sort feature on a datagrid before so this is new territory. I've
    > used dataviews before, and implemented sorting, but I've never used
    > the datagrid component before like this. Could there be something in
    > the way the DataSource is defined in the page that affects the
    > sorting?
    >
    > "Brock Allen" wrote:
    >
    >> Hmm, not sure then. Sounds like you're doing all the right things.
    >> I'd suggest making a new project with one page with the one grid and
    >> try to see if you can make it work outside of everything else -- more
    >> of a sanity check. If you can get that working then it's not the code
    >> you have for the grid, it's likley code elsewhere in the page that's
    >> thwarting the sort.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> Yep, I'm doing that. The OnSortCommand handler retrieves a dataset
    >>> from a session variable (created when the page loaded), creates a
    >>> dataview, then sorts on the SortExpression from the column clicked,
    >>> assigns the DataSource and then rebinds the grid. Only it doesn't
    >>> work. It acts like DataView.Sort doesn't work. I tried setting the
    >>> intial sort expression to a different column when the page loads,
    >>> that doesn't work either.
    >>>
    >>> "Brock Allen" wrote:
    >>>
    >>>> If you're using a DataGrid then you have to do the sorting yourself
    >>>> in the Sort event and rebind the DataGrid. It doesn't sort by
    >>>> itself, unfortunately.
    >>>>
    >>>> -Brock
    >>>> DevelopMentor
    >>>> http://staff.develop.com/ballen
    >>>>> My web datagrid isn't sorting at all. I have it wired up to a
    >>>>> handler, and I know the handler is working (being called), but no
    >>>>> sorting. The page just posts back with the same data. I hhave
    >>>>> verified that the SortExpression values are the column names. I
    >>>>> used the VS IDE to create a datasource ( a DataSet), defined a
    >>>>> table and columns, then used the datagrid Propery Builder to tie
    >>>>> eveything together. The table gets populated with data
    >>>>> correctly, I just can't get it to sort.
    >>>>>
    >>>>> Any help would be greatly appreciated.
    >>>>>
     
    Brock Allen, Oct 7, 2005
    #6
  7. Well, I finally got the Sort to work. I built a test page in my project
    using a sample I found in MSDN. That worked, so I compared the two and the
    only difference was my problem page was using a DataSet stored in a session
    variable and the example was using a DataTable. I changed my code around to
    use a DataTable instead and, voila! It sorted.

    Now my only question is, how do I get the column links to use my default
    style for navigation? I set the Class value (in the HeaderStyle property) to
    use the style in my Style Sheet but it appears to be ignoring it. I just get
    the default browser styles for <a> tags.

    Thx,

    Michael

    "Brock Allen" wrote:

    > Well, try it in the standalong page and if you can't get that to work send
    > me an email and I can give you a working sample.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    > > I'd considered doing that, but what I do if it does work? What kinds
    > > of things would prevent the sort from working? I've never tried using
    > > the sort feature on a datagrid before so this is new territory. I've
    > > used dataviews before, and implemented sorting, but I've never used
    > > the datagrid component before like this. Could there be something in
    > > the way the DataSource is defined in the page that affects the
    > > sorting?
    > >
    > > "Brock Allen" wrote:
    > >
    > >> Hmm, not sure then. Sounds like you're doing all the right things.
    > >> I'd suggest making a new project with one page with the one grid and
    > >> try to see if you can make it work outside of everything else -- more
    > >> of a sanity check. If you can get that working then it's not the code
    > >> you have for the grid, it's likley code elsewhere in the page that's
    > >> thwarting the sort.
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> http://staff.develop.com/ballen
    > >>> Yep, I'm doing that. The OnSortCommand handler retrieves a dataset
    > >>> from a session variable (created when the page loaded), creates a
    > >>> dataview, then sorts on the SortExpression from the column clicked,
    > >>> assigns the DataSource and then rebinds the grid. Only it doesn't
    > >>> work. It acts like DataView.Sort doesn't work. I tried setting the
    > >>> intial sort expression to a different column when the page loads,
    > >>> that doesn't work either.
    > >>>
    > >>> "Brock Allen" wrote:
    > >>>
    > >>>> If you're using a DataGrid then you have to do the sorting yourself
    > >>>> in the Sort event and rebind the DataGrid. It doesn't sort by
    > >>>> itself, unfortunately.
    > >>>>
    > >>>> -Brock
    > >>>> DevelopMentor
    > >>>> http://staff.develop.com/ballen
    > >>>>> My web datagrid isn't sorting at all. I have it wired up to a
    > >>>>> handler, and I know the handler is working (being called), but no
    > >>>>> sorting. The page just posts back with the same data. I hhave
    > >>>>> verified that the SortExpression values are the column names. I
    > >>>>> used the VS IDE to create a datasource ( a DataSet), defined a
    > >>>>> table and columns, then used the datagrid Propery Builder to tie
    > >>>>> eveything together. The table gets populated with data
    > >>>>> correctly, I just can't get it to sort.
    > >>>>>
    > >>>>> Any help would be greatly appreciated.
    > >>>>>

    >
    >
    >
     
    Michael Caruso, Oct 12, 2005
    #7
    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. Replies:
    2
    Views:
    1,441
    James Kanze
    Jul 6, 2010
  2. AlainCD
    Replies:
    0
    Views:
    206
    AlainCD
    Jan 12, 2006
  3. Jason
    Replies:
    0
    Views:
    390
    Jason
    Oct 4, 2006
  4. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    476
    Michael Budash
    Oct 11, 2003
  5. Íéêüëáïò Êïýñáò

    Sorting a set works, sorting a dictionary fails ?

    Íéêüëáïò Êïýñáò, Jun 10, 2013, in forum: Python
    Replies:
    12
    Views:
    161
    Ulrich Eckhardt
    Jun 10, 2013
Loading...

Share This Page