add hyber link to table or table cell web control

Discussion in 'ASP .Net Web Controls' started by Symphony, Mar 15, 2005.

  1. Symphony

    Symphony Guest

    Hi, all:

    In our web application(vb.net), we are using Table, Table Row, Table Cell
    web controls dymanically load data, we define two columns, left column likes
    header, list data titles(eg. first name, last name), right column show the
    data respectively. We would like to add a hyber link to our right column (or
    table cell), Is it doable and how to do it ? thanks.
    Symphony, Mar 15, 2005
    #1
    1. Advertising

  2. Hi,

    You should be able to instantiate a hyperlink object and add it to a cell's
    Controls collection. I've added some code below that should give you the
    idea.

    Let us know if this helps?

    Ken
    Microsoft MVP [ASP.NET]
    Toronto

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    Dim hlnk As HyperLink
    Dim tblVD As New Table
    tblVD.Visible = True
    tblVD.BackColor = Color.Ivory
    tblVD.GridLines = GridLines.Both

    Dim rforloop As Integer
    Dim cforloop As Integer
    For rforloop = 0 To 4
    Dim trow As New TableRow
    For cforloop = 0 To 3
    Dim tcell As New TableCell
    If cforloop = 2 Then
    hlnk = New HyperLink
    hlnk.Text = "Hyperlink #" & rforloop.ToString & _
    cforloop.ToString
    hlnk.NavigateUrl = "http://myurl.com?val=" & _
    rforloop.ToString & cforloop.ToString
    tcell.Controls.Add(hlnk)
    Else
    tcell.Text = cforloop.ToString
    End If
    trow.Cells.Add(tcell)
    Next cforloop
    tblVD.Rows.Add(trow)
    Next rforloop

    Dim lab As New Label
    lab.Text = "This is label text"
    tblVD.Rows(0).Cells(0).Controls.Add(lab)
    Page.Controls(1).Controls.Add(tblVD)
    End Sub

    "Symphony" <> wrote in message
    news:...
    > Hi, all:
    >
    > In our web application(vb.net), we are using Table, Table Row, Table Cell
    > web controls dymanically load data, we define two columns, left column
    > likes
    > header, list data titles(eg. first name, last name), right column show the
    > data respectively. We would like to add a hyber link to our right column
    > (or
    > table cell), Is it doable and how to do it ? thanks.
    Ken Cox [Microsoft MVP], Mar 16, 2005
    #2
    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. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    808
    Kevin Spencer
    May 17, 2005
  2. Phillip Roncoroni
    Replies:
    14
    Views:
    1,085
    Toby A Inkster
    Apr 5, 2004
  3. Clemenza

    Table cell as link

    Clemenza, Mar 19, 2005, in forum: HTML
    Replies:
    3
    Views:
    14,826
    Nico Schuyt
    Mar 19, 2005
  4. a
    Replies:
    6
    Views:
    13,614
  5. Greg N.

    empty table cell to be used as link

    Greg N., Apr 4, 2005, in forum: Javascript
    Replies:
    5
    Views:
    149
Loading...

Share This Page