PDA

View Full Version : Hyperlink a tablecell , not the text inside it


aspnoobie
03-19-04, 07:51 AM
hi experts
i am thinking of how can i hyperlink a tablecell using asp.net controls.
i know how to add a hyperlink to a tablecell by

<script language="vb" runat="server">
sub page_load()
dim r as new tablerow
dim c as new tablecell
r.Cells.add(c)
table1.rows.add(r)

Dim h As New HyperLink()
h.Text = "abc"
h.NavigateUrl = "somewebsite.htm"
c.Controls.Add(h)
end sub
</script>
<html>
<body>
<asp:table id="Table1" runat="server" border="1"/>
</body>
</html>


but the text "abc" is actually hyperlink, not the tablecell.i want to know how because i want to retrieve data from the database and create a dynamic table with all the cell hyperlinked to some pages. i work with traditional asp page before and do it using lots of "spagetti" codes. can anyone enlighten me how to use asp.net to do that. thanks in advance!

Shane
03-23-04, 08:00 PM
hi experts
i am thinking of how can i hyperlink a tablecell using asp.net controls.
i know how to add a hyperlink to a tablecell by

<script language="vb" runat="server">
sub page_load()
dim r as new tablerow
dim c as new tablecell
r.Cells.add(c)
table1.rows.add(r)

Dim h As New HyperLink()
h.Text = "abc"
h.NavigateUrl = "somewebsite.htm"
c.Controls.Add(h)
end sub
</script>
<html>
<body>
<asp:table id="Table1" runat="server" border="1"/>
</body>
</html>


but the text "abc" is actually hyperlink, not the tablecell.i want to know how because i want to retrieve data from the database and create a dynamic table with all the cell hyperlinked to some pages. i work with traditional asp page before and do it using lots of "spagetti" codes. can anyone enlighten me how to use asp.net to do that. thanks in advance!
Think about using a datagrid or something similiar and modify the column/row templates. That will get you what you want.

Daemon
04-02-04, 10:37 AM
hi experts
i am thinking of how can i hyperlink a tablecell using asp.net controls.
i know how to add a hyperlink to a tablecell by

<script language="vb" runat="server">
sub page_load()
dim r as new tablerow
dim c as new tablecell
r.Cells.add(c)
table1.rows.add(r)

Dim h As New HyperLink()
h.Text = "abc"
h.NavigateUrl = "somewebsite.htm"
c.Controls.Add(h)
end sub
</script>
<html>
<body>
<asp:table id="Table1" runat="server" border="1"/>
</body>
</html>


but the text "abc" is actually hyperlink, not the tablecell.i want to know how because i want to retrieve data from the database and create a dynamic table with all the cell hyperlinked to some pages. i work with traditional asp page before and do it using lots of "spagetti" codes. can anyone enlighten me how to use asp.net to do that. thanks in advance!

The only thing I can think of would be to use the <div> tag inside the cell and set an onclick event handler to make it a link.