ASP.NET Dynamic Table


C

Crouchie1998

Hi All,

Am using VS2010 with Framework 4.0 in VB.NET

I have a table which I wish to create on page load which isn't database driven

I can create the table single column using new LinkLabel controls but I wish
to have the links in 3 or 4 columns, not just one. Example

At the moment:

LinkLabel1
LinkLabel2
LinkLabel3
LinkLabel4
LinkLabel4
LinkLabel6
....

Would like them:

LinkLabel1 LinkLabel2 LinkLabel3
LinkLabel4 LinkLabel5 LinkLabel6
....

This is the code I have so far, taken from an example & changed for my
requirements:

Private Sub CreateRootTable()
PlaceHolder1.Controls.Clear()

Dim tblRows As Integer = 60
Dim tblCols As Integer = 1 ' Changing to 3 just repeats the same
link 3 times
Dim tbl As Table = New Table()
PlaceHolder1.Controls.Add(tbl)
For i As Integer = 0 To tblRows - 1
Dim tr As TableRow = New TableRow()
For j As Integer = 0 To tblCols - 1
Dim tc As TableCell = New TableCell()
Dim hl As HyperLink = New HyperLink()
hl.Text = "Some Text Here " & (i + 1)
hl.ToolTip = "Click here to download"
hl.NavigateUrl = "/URL HERE"
hl.Font.Underline = False
hl.Font.Size = FontUnit.Medium
' hl.Target = "_self"
tc.Controls.Add(hl)
tr.Cells.Add(tc)
Next j
tbl.Rows.Add(tr)
Next i

ViewState("dynamictable") = True
End Sub

Changing the column variable to 3 just does the following

LinkLabel1 LinkLabel1 LinkLabel1
LinkLabel2 LinkLabel2 LinkLabel2
LinkLabel3 LinkLabel3 LinkLabel3
LinkLabel4 LinkLabel4 LinkLabel4
LinkLabel5 LinkLabel5 LinkLabel5
LinkLabel6 LinkLabel6 LinkLabel6

When I am looking to centre them and space them equally on screen like so:

LinkLabel1 LinkLabel2
LinkLabel3
LinkLabel4 LinkLabel5
LinkLabel6

Please help

Thanks in advance
 
Ad

Advertisements

C

Crouchie1998

Disregard post. Not sure what Microsoft are doing posting this message many
times

All the time I post there is an error & it asks to try again yet it get's
posted
 
Ad

Advertisements


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

Top