How do I change the DataGrid column order programmatically?

Discussion in 'ASP .Net Datagrid Control' started by Sudhanshu Thakur, Jul 12, 2003.

  1. I use a single datagrid to load several different types of data depending
    upon some user driven criteria. The AutoGenerateColumns property for the
    datagrid is set to true. I also dynamically add a hyperlink template column
    from an user control using the LoadTemplate method (thanks Dino Esposito).
    The problem is that the template column always appears before the
    autogenerated columns. What I want is for the template column to appear as
    column # 2, sandwiched between two bound columns.

    Is there any way to control the column position of the template column when
    AutoGenerateColumns is set to true? Adding bound columns programmatically
    in the Page_Load and slipping the template columns in between the two bound
    columns sound like too much work. I am hoping for simple property I can set
    to manipulate the column order.

    Thanks,
    S. Thakur
     
    Sudhanshu Thakur, Jul 12, 2003
    #1
    1. Advertising

  2. Sudhanshu Thakur

    Alvin Bruney Guest

    The column order is based on the selection clause of the sql statement,
    change the order of the sql query. If you want to adjust the order of the
    template column you are out of luck. Items in the column collection come
    before autobound columns.

    "Sudhanshu Thakur" <> wrote in message
    news:...
    > I use a single datagrid to load several different types of data depending
    > upon some user driven criteria. The AutoGenerateColumns property for the
    > datagrid is set to true. I also dynamically add a hyperlink template

    column
    > from an user control using the LoadTemplate method (thanks Dino Esposito).
    > The problem is that the template column always appears before the
    > autogenerated columns. What I want is for the template column to appear as
    > column # 2, sandwiched between two bound columns.
    >
    > Is there any way to control the column position of the template column

    when
    > AutoGenerateColumns is set to true? Adding bound columns programmatically
    > in the Page_Load and slipping the template columns in between the two

    bound
    > columns sound like too much work. I am hoping for simple property I can

    set
    > to manipulate the column order.
    >
    > Thanks,
    > S. Thakur
    >
    >
     
    Alvin Bruney, Jul 13, 2003
    #2
    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. Ike
    Replies:
    1
    Views:
    5,160
  2. RC
    Replies:
    3
    Views:
    735
    Roedy Green
    Jun 29, 2007
  3. K Schleyer

    Can I programmatically change width/height of column in edit mode

    K Schleyer, Jan 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    161
    K Schleyer
    Jan 16, 2004
  4. Ravi Gudlavalleti

    How do I change the headertext of a datagrid column programmatically

    Ravi Gudlavalleti, Jun 17, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    224
    Ken Cox [Microsoft MVP]
    Jun 18, 2004
  5. Replies:
    2
    Views:
    262
    jyoti
    Aug 19, 2006
Loading...

Share This Page