J
Jeremy
I am creating some TemplateColumns in a data grid dynamically and set the
"ItemStyle.Width" property on the column. I also have some static columns
that I set the width on at design-time.
The design-time widths transfer over to the HTML, the dynamic widths do not.
Here is my code to create the column:
---------------------8<---------------------
Private Function CreateTemplateColumn( _
ByVal itemTemplate As ITemplate, _
ByVal headerText As String, _
ByVal pixelWidth As Integer) _
As TemplateColumn
Dim retColumn As New TemplateColumn
With retColumn
.ItemTemplate = itemTemplate
.HeaderText = headerText
.ItemStyle.Width = New Unit(pixelWidth, UnitType.Pixel)
End With
Return retColumn
End Function
---------------------8<---------------------
and call the function on page_load:
---------------------8<---------------------
Private Sub Page_Load(...) Handles MyBase.Load
dgOptions.Columns.AddAt(4, _
CreateTemplateColumn(_
New GenericBoundTextTemplate("option_id") _
, "ID", 50))
Me.dgOptions.DataBind()
End Sub
---------------------8<---------------------
Thanks,
Jeremy
"ItemStyle.Width" property on the column. I also have some static columns
that I set the width on at design-time.
The design-time widths transfer over to the HTML, the dynamic widths do not.
Here is my code to create the column:
---------------------8<---------------------
Private Function CreateTemplateColumn( _
ByVal itemTemplate As ITemplate, _
ByVal headerText As String, _
ByVal pixelWidth As Integer) _
As TemplateColumn
Dim retColumn As New TemplateColumn
With retColumn
.ItemTemplate = itemTemplate
.HeaderText = headerText
.ItemStyle.Width = New Unit(pixelWidth, UnitType.Pixel)
End With
Return retColumn
End Function
---------------------8<---------------------
and call the function on page_load:
---------------------8<---------------------
Private Sub Page_Load(...) Handles MyBase.Load
dgOptions.Columns.AddAt(4, _
CreateTemplateColumn(_
New GenericBoundTextTemplate("option_id") _
, "ID", 50))
Me.dgOptions.DataBind()
End Sub
---------------------8<---------------------
Thanks,
Jeremy