Sorting dynamically created columns in the datagird

Discussion in 'ASP .Net' started by Gaurav Gargate, Oct 5, 2004.

  1. To Group,

    I am creating a datagrid in an ASP.NET project (C#) at the design time.
    I will be adding the columns to the datagird at run time.
    The number of columns, name of the columns, data in the rows etc. will all
    be decided on the run time.
    I am using the simple grid.Columns.Add(BoundColumn).... method.

    BUT I am not able to sort these columns even if the AllowSorting property
    has been set to true.
    I cannot capture any event when I click the header of the data grid.
    The page is posted back on clicking the header but no event is fired.

    How can I sort the columns created on the run time.

    Thanks in Advance,
    Gaurav
     
    Gaurav Gargate, Oct 5, 2004
    #1
    1. Advertisements

  2. hi Gaurav,
    You need to give the sort expression for each column that you are adding.
    In the datagrid_sortcommand event you have to get the sortexpression of the
    datagrid and sort the datasource on that column and rebind the datasource to
    the datagrid.
    Check out this link for an exampl
    http://samples.gotdotnet.com/quicks...ef/webctrl/datagrid/doc_datagrid.aspx#sorting
    HTH
    srini

    "Gaurav Gargate" wrote:

    > To Group,
    >
    > I am creating a datagrid in an ASP.NET project (C#) at the design time.
     
    =?Utf-8?B?c3Jpbmk=?=, Oct 5, 2004
    #2
    1. Advertisements

  3. Hi Srini...

    Thanks for the urgent reply.
    Infact I had tried out everything that is displayed on the link you
    sent. Just forgot to mention that in my post.. :-(

    The problem was that the dynamically generated columns on the datagrid
    did not generate/evoke any event. So was not able to catch any of them.

    I have however found a way round. I have allowed the auto creation of
    columns on the datagrid and bound the data grid to the dataset I get.
    This has resulted in dynamic columns, as well as all the events are been
    captured.

    Regards,
    Gaurav





    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Gaurav Gargate, Oct 6, 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. =?Utf-8?B?U3VtYQ==?=
    Replies:
    2
    Views:
    613
    =?Utf-8?B?U3VtYQ==?=
    Dec 23, 2004
  2. Replies:
    5
    Views:
    846
  3. Replies:
    1
    Views:
    405
    Winista
    Jun 28, 2006
  4. msimmons
    Replies:
    0
    Views:
    784
    msimmons
    Jul 16, 2009
  5. Anna Schmidt

    eventhandler of a programmatically created datagird

    Anna Schmidt, Mar 2, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    199
  6. Korneel Vandamme

    sorting dynamically created columns in a datagrid

    Korneel Vandamme, Sep 30, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    213
    Korneel Vandamme
    Sep 30, 2004
  7. MattB

    Column order and dynamically created columns

    MattB, Dec 1, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    219
    MattB
    Dec 1, 2004
  8. Keefe Goldfisher via .NET 247

    Sizing text entry boxes on in-place editing of datagrid row with dynamically created columns

    Keefe Goldfisher via .NET 247, Mar 7, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    284
    Keefe Goldfisher via .NET 247
    Mar 7, 2005
Loading...