How to adjust column width in Datagrid web control?

Daspoo

Regular
Joined
Jan 27, 2003
Messages
99
Location
Fort Walton Beach, Florida
Does anyone know how to manually set the width of individual columns in a Datagrid Web Control? I'm speaking of the physical width of each column, and not the amount of data/characters displayed in each. A colleague and I have tried a number of different attempts, including going into the "ItemCreated" and "ItemDataBound" events of the Datagrid control, with no luck. Any help would be most appreciated!
 
all of the "Styles" in either <asp:template> or <asp:boundcolumn> all have a "-Width" attribute

ex:
HeaderStyle-Width="100px"
FooterStyle-Width="100px"
or
ItemStyle-Width="100px"
 
Re:

Is there anyway to set the width within the .aspx.vb code? The control has AutoGenerateColumns set to True, and in the HTML view of the .aspx page, the only tag related to the datagrid is the <asp:datagrid> tag itself.
 
In the aspx:
<asp:datagrid OnItemCreated="Item_Created"

In the code behind:
Public Function Item_Created(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
e.Item.Cells(0).Width = Unit.Pixel(100)
End Function
 
Back
Top