all groups > asp.net datagrid control > december 2005 >
You're in the

asp.net datagrid control

group:

Column width


Column width Tumurbaatar S.
12/21/2005 8:36:31 PM
asp.net datagrid control: How to retrieve _real_ width of DataGrid's column?
At design-time I set width of template columns with the following way:

<headerstyle width="80px"></headerstyle>

This sets the minimal width of the column and during run-time if the column
contains a long text, it can expand. I need to get an exact value of the
width,
at server or client side, and apply this width to another column.
I.e. what I want is 2 columns with same width.


Re: Column width Ahmed Fouad
12/22/2005 12:21:28 PM
Try setting CSS inline style="table-layout: fixed" and specify widths of
each column using <HeaderStyle/> element or as HeaderStyle-Width="...px"
attribute of each column in <Columns> collection. DONOT specify <ItemStyle
Width="...px"/> or ItemStyle-Width="...px" attribute.

When table-layout style attribute set to fixed, at client-side, IE will use
the FIRST row of datagrid (i.e the first row of html table) to set the
widths of each of its columns. If no more than one row specifies widths then
the table will appear as we want it to appear". Otherwise IE will ignore
explicit width values and revert to dynamic calculation of column widths.

[quoted text, click to view]

AddThis Social Bookmark Button