Asp.net table control problem rowspan?

  • Thread starter Thread starter moto
  • Start date Start date
M

moto

Guest
I have an asp.net table control that works great except when I add a rowspan to the table. It seems to add an extra cell(s) to the right of the current column. This is my first time messing around with asp.net tables and I was wondering if anyone could help me! Here is the code I created so far (any help is greatly apprehiated!):

Table1.Rows.Clear()
Table1.BackColor = System.Drawing.Color.LightGray
Table1.BorderWidth = 1
Table1.BorderStyle = BorderStyle.Solid
Table1.CellSpacing = 0
Table1.CellPadding = 1
Table1.Font.Size = 10
Dim x As Integer = 0
Dim tme As DateTime = CDate("7:30")
For iRow As Integer = 0 To 115
Dim Row As New TableRow()

For iCol As Integer = 0 To 4
Dim Cell As New TableCell()
Cell.BorderColor = System.Drawing.Color.Black 'cell formatting
Cell.BorderStyle = BorderStyle.Solid
Cell.BorderWidth = 1

If iCol = 0 Then 'time column (0) needs to have smaller cell
Cell.Width = 40
Else
Cell.Width = 150 'any column greater than 0 is set to 150
End If

If iRow = 0 And (iCol = 0 Or iCol = 1 Or iCol = 2 Or iCol = 3 Or iCol = 4) Then 'Header for Row 1 for the 5 columns
Cell.HorizontalAlign = HorizontalAlign.Center
Cell.Font.Bold = True
Select Case iCol
Case 0
Cell.Text = "Time"
Case 1
Cell.Text = "Block 1"
Case 2
Cell.Text = "Block 2"
Case 3
Cell.Text = "Block 3"
Case 4
Cell.Text = "Block 4"
End Select
Cell.RowSpan = 1
ElseIf (iCol = 0 And iRow <> 0) Then
Cell.Text = tme.ToString("H:mm")
tme = tme.AddMinutes(5).ToShortTimeString
Cell.RowSpan = 1
ElseIf ((iRow = 15) And (iCol = 1)) Or (iRow = 5 And iCol = 2) Then
Cell.RowSpan = 4
Cell.Text = "This is a test!!"

Else
Cell.Text = iRow & " " & iCol
Cell.RowSpan = 1
'Row.Cells.Remove(Cell)
End If
Row.Cells.Add(Cell)
Table1.Rows.Add(Row)
Next

Next
 
Back
Top