ASP.NET Dynamic Table

Discussion in 'ASP .Net' started by Crouchie1998, Sep 19, 2010.

  1. Crouchie1998

    Crouchie1998 Guest

    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
    Crouchie1998, Sep 19, 2010
    #1
    1. Advertising

  2. Crouchie1998

    Crouchie1998 Guest

    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
    Crouchie1998, Sep 19, 2010
    #2
    1. Advertising

  3. Crouchie1998

    Crouchie1998 Guest

    An error occurred while sending your pos
    --------------------------------------------------------------------------------

    We're sorry, but there was a problem with the system and your post was not
    received. The error has been reported to Operations and will be investigated
    as soon as possible. Please try again later.



    "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
    Crouchie1998, Sep 19, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Glos
    Replies:
    0
    Views:
    634
    Rick Glos
    Jul 8, 2003
  2. David Williams
    Replies:
    2
    Views:
    1,107
    Jacob Yang [MSFT]
    Aug 12, 2003
  3. =?Utf-8?B?QkxpVFpXaU5H?=

    Adding dynamic LinkButton to dynamic table

    =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    703
    =?Utf-8?B?QkxpVFpXaU5H?=
    Jul 27, 2005
  4. opius
    Replies:
    0
    Views:
    1,168
    opius
    Jun 17, 2011
  5. Kooki

    Dynamic Table with Dynamic Button inside

    Kooki, Sep 15, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    141
    Kooki
    Sep 15, 2005
Loading...

Share This Page