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!
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!