Width property not transfering

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Repost: DataGrid column width bug 3
DataGrid Column Width is broken - is this a bug? 5
Property 1
limit colunm width in gridview 1
GridView Column Width 3
Property. 3
Property 1
Property 0

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top