sorting in a datagrid

Discussion in 'ASP .Net Web Controls' started by Julia, Jun 12, 2006.

  1. Julia

    Julia Guest

    Hi,

    I am developing a composite control, so I am writing all my code in a *.cs
    file. One of the component in my composite control is a datagrid. The
    datagrid is populated from a dataview by using DataBind(). The user should be
    able to sort the datagrid my clicking the header of the columns. Anyone has
    a sample of this? It would be really helpful for me. I only want to write c#
    code to do this.

    Thanks
    Julia
     
    Julia, Jun 12, 2006
    #1
    1. Advertising

  2. Julia

    Julia Guest

    Hi

    It is working when I use AutoGenerateColumns = true; but not when I use
    AutoGenerateColumns = false;.

    Any ideas?

    /Julia

    "Julia" wrote:

    > Hi,
    >
    > I am developing a composite control, so I am writing all my code in a *.cs
    > file. One of the component in my composite control is a datagrid. The
    > datagrid is populated from a dataview by using DataBind(). The user should be
    > able to sort the datagrid my clicking the header of the columns. Anyone has
    > a sample of this? It would be really helpful for me. I only want to write c#
    > code to do this.
    >
    > Thanks
    > Julia
     
    Julia, Jun 12, 2006
    #2
    1. Advertising

  3. hi Julia,
    you need to attach to the SortCommand handler for your datagrid in code and
    then do what you need to do in this event when sorting is enabled on the
    grid. One possible mistake i can think of why you sorting is not working on
    your grid is possibly because when you set autogenerate columns to false,
    you are probably also trying to set a templatecolumn in the HeaderTemplate
    <HeaderTemplate></HeaderTemplate> . In this case make sure you add a control
    in your HeaderTemplate that can postback like a button control or a
    linkbutton, imagebutton etc..
    try these resources :
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.allowsorting.aspx

    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.sortcommand.aspx

    good luck,
    Alessandro Zifiglio
    "Julia" <> ha scritto nel messaggio
    news:...
    > Hi
    >
    > It is working when I use AutoGenerateColumns = true; but not when I use
    > AutoGenerateColumns = false;.
    >
    > Any ideas?
    >
    > /Julia
    >
    > "Julia" wrote:
    >
    >> Hi,
    >>
    >> I am developing a composite control, so I am writing all my code in a
    >> *.cs
    >> file. One of the component in my composite control is a datagrid. The
    >> datagrid is populated from a dataview by using DataBind(). The user
    >> should be
    >> able to sort the datagrid my clicking the header of the columns. Anyone
    >> has
    >> a sample of this? It would be really helpful for me. I only want to write
    >> c#
    >> code to do this.
    >>
    >> Thanks
    >> Julia
     
    Alessandro Zifiglio, Jun 13, 2006
    #3
  4. Julia

    Riki Guest

    If you're using BoundColumns, don't forget to set the SortExpression
    property for each column.

    --

    Riki

    "Julia" <> wrote in message
    news:...
    > Hi
    >
    > It is working when I use AutoGenerateColumns = true; but not when I use
    > AutoGenerateColumns = false;.
    >
    > Any ideas?
    >
    > /Julia
    >
    > "Julia" wrote:
    >
    >> Hi,
    >>
    >> I am developing a composite control, so I am writing all my code in a
    >> *.cs
    >> file. One of the component in my composite control is a datagrid. The
    >> datagrid is populated from a dataview by using DataBind(). The user
    >> should be
    >> able to sort the datagrid my clicking the header of the columns. Anyone
    >> has
    >> a sample of this? It would be really helpful for me. I only want to write
    >> c#
    >> code to do this.
    >>
    >> Thanks
    >> Julia
     
    Riki, Jun 13, 2006
    #4
    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:
    391
    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:
    478
    Michael Budash
    Oct 11, 2003
  5. Íéêüëáïò Êïýñáò

    Sorting a set works, sorting a dictionary fails ?

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

Share This Page