Click to See Complete Forum and Search --> : [RESOLVED] TableCell Width Problem


birre
04-20-2007, 02:28 AM
Hi,

I also asked this on the ASP forum, but it should be in here. THis is my problem :
I'm trying to dynamically create a table , showing up like a year calendar.
I have a table on my page, and trying this code on the page load :

Dim year = DateTime.Now.Year
Dim i As Integer
Dim j As Integer
For i = 1 To 12
Dim r As TableRow = New TableRow()
For j = 0 To DateTime.DaysInMonth(year, i)
Dim c As TableCell = New TableCell()
If (j = 0) Then
c.Controls.Add(New LiteralControl("Maand" + i.ToString()))
c.Text = "maand" + i.ToString()
c.CssClass = "YEARLEFT"
c.Width = Unit.Pixel(100)
Else
c.Controls.Add(New LiteralControl(j.ToString()))
c.Text = j.ToString()
c.CssClass = "YEARDAY"
c.Width = Unit.Pixel(50)
End If
r.Cells.Add(c)
Next
tblCalendar.Rows.Add(r)
Next

The c.Width = Unit.Pixel() are giving me a big headache, it just won't work to give the width of the tablecells.
Also with c.Style("width") = "100" it isn't working.... the table only takes the cellpading property, but won't adjust the width of the cells

Any help? :confused:

thank you!

birre
04-20-2007, 03:42 AM
Resolved!

For every cell, I made a label, and placed the width on the label :)
this is working, and is easy to place text and style on the label!

thanks

eilering
12-28-2009, 03:56 AM
This works
Dim tc3 As TableCell = New TableCell()
Dim tb As Table = New Table
tc3.Height = 10
tc3.Width = 20