I would like to draw a table with 2 columns. The first column will have 2 rows each one containing a and b letters respectively and the second column containing no rows. here is my code.
Public Class trialtable
Inherits System.Web.UI.Page
Protected Sub trialtable(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim trial As DataTable
trial = New DataTable
Dim tbl As New Table()
Dim szName As String = ""
Dim szNumber As String = ""
Dim szsadasd As String = ""
tbl.BorderColor = Drawing.Color.Black
tbl.BorderWidth = 1
tbl.CellPadding = 0
tbl.CellSpacing = 0
For i As Integer = 0 To 1
Dim tr As New TableRow()
Dim tc1 As New TableCell()
Dim tc2 As New TableCell()
Dim tc3 As New TableCell()
tc1.Controls.Add(New LiteralControl(szName))
tc2.Controls.Add(New LiteralControl(szNumber))
tc3.Controls.Add(New LiteralControl(szsadasd))
tc1.BorderColor = Drawing.Color.Black
tc1.BorderWidth = 1
tc2.BorderColor = Drawing.Color.Black
tc2.BorderWidth = 1
tc3.BorderColor = Drawing.Color.Black
tc3.BorderWidth = 1
tr.Cells.Add(tc1)
tr.Cells.Add(tc2)
tr.Cells.Add(tc3)
tbl.Controls.Add(tr)
Next
Me.Controls.Add(tbl)
End Sub
End Class
In order to place the value a
in the first cell of the first row, and b
in the first cell of the 2nd row, and have nothing in the 2nd cell of both rows, replace the following lines of code...
tc1.Controls.Add(New LiteralControl(szName))
tc2.Controls.Add(New LiteralControl(szNumber))
With the following code...
If i = 0 Then
tc1.Controls.Add(New LiteralControl("a"))
Else
tc1.Controls.Add(New LiteralControl("b"))
End If
tc2.Controls.Add(New LiteralControl(" "))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.