PC Review


Reply
Thread Tools Rate Thread

ASP.NET Dynamic Table

 
 
D C
Guest
Posts: n/a
 
      19th Sep 2010
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic pivot table linked to dynamic excel spreadsheets FErd Microsoft Excel Worksheet Functions 0 29th Apr 2010 10:44 PM
dynamic query to insert rows from sql server attached table to mdb table webdb_advisor@hotmail.com Microsoft Access VBA Modules 4 29th Oct 2005 05:59 PM
Adding dynamic LinkButton to dynamic table =?Utf-8?B?QkxpVFpXaU5H?= Microsoft ASP .NET 0 27th Jul 2005 01:21 AM
create a source table from a special pasted value dynamic crossed table Arthemus Microsoft Excel Programming 1 29th Sep 2003 08:59 PM
Re: Dynamic Table with Dynamic LinkButtons Rick Glos Microsoft ASP .NET 0 8th Jul 2003 02:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 AM.