Hyperlink Column URGENT!!!

  • Thread starter Christopher Calhoun
  • Start date
C

Christopher Calhoun

Does anyone Know how to programmatically assign all the columns in a
DataGrid with AutoGenerateColumns set to true as Hyperlink Columns?

Thanks in Advance....
 
K

Ken Cox [Microsoft MVP]

If it is urgent, you might want to check the January 19th answer to your
post in microsoft.public.dotnet.framework.aspnet.datagridcontrol

Anyway, here's the old answer:


Hi Christopher,
Not sure why you'd want to do that, but here's a way to substitute the text
from a cell with a hyperlink:
Private Sub DataGrid1_ItemDataBound _
(ByVal sender As Object, ByVal e As _
System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim tblcell As TableCell
Dim intCounter As Integer
Dim hlnkcntrl As HyperLink
For intCounter = 0 To e.Item.Cells.Count - 1
tblcell = e.Item.Cells(intCounter)
hlnkcntrl = New HyperLink
hlnkcntrl.Text = tblcell.Text
hlnkcntrl.NavigateUrl = "thepage.aspx"
tblcell.Text = ""
tblcell.Controls.Add(hlnkcntrl)
Next
End Sub
Ken
MVP [ASP.NET]
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top