469,352 Members | 2,026 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

DataGrid Column Width

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.
Nov 15 '05 #1
3 30792
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" <fr***@frank.com> wrote in message
news:#m**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 15 '05 #2
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" <fr***@frank.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

Nov 15 '05 #3
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" <sa******@sct.co.in> wrote in message
news:e$**************@TK2MSFTNGP12.phx.gbl...
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" <fr***@frank.com> wrote in message
news:#m**************@TK2MSFTNGP12.phx.gbl...
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.


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Eva | last post: by
reply views Thread by Randy | last post: by
reply views Thread by RA | last post: by
1 post views Thread by Amos | last post: by
2 posts views Thread by nj | last post: by
3 posts views Thread by Mike Fellows | last post: by
1 post views Thread by salih ataoz | last post: by
reply views Thread by Claire | last post: by
3 posts views Thread by Francois | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.