DataGrid Column Width

Discussion in 'ASP .Net Datagrid Control' started by frank, Jul 21, 2003.

  1. frank

    frank Guest

    How do I set the column width of a column in a DataGrid programatically (in
    ASP.NET web pages)?

    I understand I may have to use DataGridTableStyle, but I can't get this to
    work with web pages.

    Any help would be appreciated.
    frank, Jul 21, 2003
    #1
    1. Advertising

  2. frank

    Saravana Guest

    you can programmatically change width of the column like this,

    datagrid1.Columns(0).ItemStyle.Width.Pixel(150)

    or

    datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)


    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "frank" <> wrote in message
    news:#...
    > How do I set the column width of a column in a DataGrid programatically

    (in
    > ASP.NET web pages)?
    >
    > I understand I may have to use DataGridTableStyle, but I can't get this to
    > work with web pages.
    >
    > Any help would be appreciated.
    >
    >
    Saravana, Jul 21, 2003
    #2
    1. Advertising

  3. Hi Frank,

    You can use DataGrid.Columns[X].ItemStyle.Width , here goes an example:
    this.locationgrid.Columns[2].Visible = this.locationgrid.Columns[3].Visible
    = false;

    this.locationgrid.Columns[1].ItemStyle.Width= 460;



    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "frank" <> wrote in message
    news:%...
    > How do I set the column width of a column in a DataGrid programatically

    (in
    > ASP.NET web pages)?
    >
    > I understand I may have to use DataGridTableStyle, but I can't get this to
    > work with web pages.
    >
    > Any help would be appreciated.
    >
    >
    Ignacio Machin, Jul 21, 2003
    #3
  4. Just remember, that whatever you do in the code, meaning whatever HTML it
    produces, a browser on client's machine will consider it as a recomendation
    rather than an instruction.

    Since you can hardly be sure what width the browser will assign to your
    columns, it's not a good idea to rely on exact column width in your design.

    Eliyahu

    "Saravana" <> wrote in message
    news:e$...
    > you can programmatically change width of the column like this,
    >
    > datagrid1.Columns(0).ItemStyle.Width.Pixel(150)
    >
    > or
    >
    > datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)
    >
    >
    > --
    > Saravana
    > Microsoft India Community Star,
    > MCAD,SE,SD,DBA.
    >
    >
    > "frank" <> wrote in message
    > news:#...
    > > How do I set the column width of a column in a DataGrid programatically

    > (in
    > > ASP.NET web pages)?
    > >
    > > I understand I may have to use DataGridTableStyle, but I can't get this

    to
    > > work with web pages.
    > >
    > > Any help would be appreciated.
    > >
    > >

    >
    >
    Eliyahu Goldin, Jul 21, 2003
    #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. AndrewF
    Replies:
    1
    Views:
    766
    Bruce Barker
    Oct 10, 2005
  2. Charleees
    Replies:
    2
    Views:
    8,207
    Eliyahu Goldin
    Jun 20, 2006
  3. ssk
    Replies:
    5
    Views:
    5,501
    Jukka K. Korpela
    Oct 30, 2006
  4. David Basford
    Replies:
    3
    Views:
    2,419
    BootNic
    Sep 30, 2007
  5. Carl Howarth

    DG Column Width vs Table Column Width

    Carl Howarth, Oct 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    263
    Eliyahu Goldin
    Oct 24, 2004
Loading...

Share This Page