add hyber link to table or table cell web control

S

Symphony

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.
 
K

Ken Cox [Microsoft MVP]

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
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top