Click to See Complete Forum and Search --> : Web datagrid column width


hogmahub
March 27th, 2004, 01:38 PM
How do I set the column widths of a web datagrid at run time?

I have an unbound datagrid which is populated by a SQL stored proc which returns variable numbers of columns. The tablestyles option only appears to work for Windows forms.

Thanks in advance

gasperCasper
March 28th, 2004, 12:50 PM
I dont think you can set datagrid column width at runtime.

The reason; this code is executed client side when the browser decides width of the column based on the text present in the column. Even though u set the width of the column in your server code, the browser changes it based on the length of the text to be displayed (text is never truncated).


try researching on CSS and try to set a class (<asp:dataGrid class="someclass" id="someid" ...>) for your datagrid object to restrict / get required width,

HTH