TableCell question

F

fniles

In a table cell, I would like to put in something like "1 2 3" where each
number is a hyperlink like so:
<tr>
<td width="100%" align="center">
<a href="page_1.htm">1</a>
<a href="page_2.htm">2</a>
<a href="page_3.htm">3</a>
</td>
</tr>

How can I do that within the ASP server code using tablecell, tablerow, etc
? Thank you.

Dim tempCell As New TableCell
Dim Row As New TableRow
Dim MyHyperlink As New HyperLink

MyHyperlink.NavigateUrl = sUrl & "?ID=" & lID
MyHyperlink.Text = sText
tempCell.Controls.Add(MyHyperlink)
Row.Cells.Add(tempCell)
tbl.Rows.Add(Row)
 
R

Rahul Soni

What about this?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim tbl As New Table
Dim tblRow As New TableRow
Dim i As Integer
Dim cell As TableCell
For i = 1 To 10
cell = New TableCell()
cell.Text = "<a href='page" & i & ".htm'>" & i & "</a>"
tblRow.Cells.Add(cell)
Next
tbl.Rows.Add(tblRow)
Me.Controls.Add(tbl)
End Sub
 
G

Guest

In a table cell, I would like to put in something like "1 2 3" where each
number is a hyperlink like so:
<tr>
    <td width="100%" align="center">
    <a href="page_1.htm">1</a>
    <a href="page_2.htm">2</a>
    <a href="page_3.htm">3</a>
    </td>
  </tr>

How can I do that within the ASP server code using tablecell, tablerow, etc
? Thank you.

        Dim tempCell As New TableCell
        Dim Row As New TableRow
        Dim MyHyperlink As New HyperLink

        MyHyperlink.NavigateUrl = sUrl & "?ID=" & lID
        MyHyperlink.Text = sText
        tempCell.Controls.Add(MyHyperlink)
        Row.Cells.Add(tempCell)
        tbl.Rows.Add(Row)

You need to add a loop as Rahul is already mentioned. Either use
FOR...NEXT or WHILE...END WHILE

Example:
http://www.startvbdotnet.com/language/loops.aspx

Hope this helps
 
F

fniles

That will do it.
Thanks !

Rahul Soni said:
What about this?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim tbl As New Table
Dim tblRow As New TableRow
Dim i As Integer
Dim cell As TableCell
For i = 1 To 10
cell = New TableCell()
cell.Text = "<a href='page" & i & ".htm'>" & i & "</a>"
tblRow.Cells.Add(cell)
Next
tbl.Rows.Add(tblRow)
Me.Controls.Add(tbl)
End Sub
--
Cheers,
Rahul Soni

www.dotnetscraps.com
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top