SortExpression makes SortCommand event not to trig

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF1bA==?=, Sep 22, 2005.

  1. Hi!

    When I add a bound column programatically, like:

    BoundColumn bc = new BoundColumn();
    bc.DataField = "myField";
    bc.SortExpression = "myField";
    myGrid.Columns.Add(bc);

    the SortCommand event does not trig at all!

    If I replace the code whith the markup syntax in the ascx file, it works
    fine. I've google around but the only solution to the problem seemes to be
    moving the code to Page_Init.

    This is not possible because at that time I dont know the structure of the
    table. Depending on a selection in a dropdown, i get diffrent datatables to
    bind with the grid. The selectedindexchanged event on the dropdown will not
    fire until much later in execution, so in Page_Init I wouldn't know what was
    selected yet. Furthermore i cant understand what Page_Init has to do with all
    of this.

    I'm confused, any ideas?

    Thanks,
    Paul
     
    =?Utf-8?B?UGF1bA==?=, Sep 22, 2005
    #1
    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. John Sturgeon

    DataGrid SortCommand event not triggered

    John Sturgeon, Nov 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    704
    John Sturgeon
    Dec 2, 2003
  2. Mo
    Replies:
    0
    Views:
    585
  3. sonic
    Replies:
    1
    Views:
    664
    John Saunders
    Jan 7, 2005
  4. =?Utf-8?B?UGF1bA==?=

    Setting SortExpression programmatically

    =?Utf-8?B?UGF1bA==?=, Sep 26, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    6,289
    Kalpesh
    Sep 27, 2005
  5. Manav

    SortCommand Event in DataGrid

    Manav, Feb 25, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    216
    Scott Mitchell [MVP]
    Feb 25, 2004
  6. sa siva via .NET 247

    SortCommand and PageIndexChange event not firing

    sa siva via .NET 247, Mar 24, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    326
    Cole Trickle
    May 5, 2005
  7. ae
    Replies:
    2
    Views:
    207
    venuprs
    Apr 8, 2005
  8. biru
    Replies:
    2
    Views:
    450
Loading...