Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET Dynamic Table

Reply
Thread Tools

ASP.NET Dynamic Table

 
 
Crouchie1998
Guest
Posts: n/a
 
      09-19-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
 
 
 
 
Crouchie1998
Guest
Posts: n/a
 
      09-19-2010
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

"Crouchie1998" wrote:

> 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

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 table with dynamic controls and mySql ... opius ASP .Net 0 06-17-2011 08:55 AM
Dynamic Table with Dynamic Button inside Kooki ASP .Net Web Controls 0 09-15-2005 07:12 PM
Adding dynamic LinkButton to dynamic table =?Utf-8?B?QkxpVFpXaU5H?= ASP .Net 0 07-27-2005 12:21 AM
Could not load type VTFixup Table from assembly Invalid token in v-table fix-up table. David Williams ASP .Net 2 08-12-2003 07:55 AM
Re: Dynamic Table with Dynamic LinkButtons Rick Glos ASP .Net 0 07-08-2003 01:09 PM



Advertisments