TableCell question

  • Thread starter Thread starter fniles
  • Start date Start date
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)
 
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
 
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
 
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
 
Back
Top