Change Datagrid Column to Hyperlink

cyclonebri

Regular
Joined
Jul 30, 2003
Messages
93
Location
Ames, IA, USA
Is it possible to change a dynamically generated Datagrid column after generation to become a hyperlink column with the value returned from the dataset displayed, as well as used in the hyperlink?

For example, I currently have the datagrid returning and displaying specific information from a table, including the ID number for that data. I want to change the display from just the ID number as text to the ID number as a hyperlink to a new page that has the address like this:

newpage.aspx?IDNUM=<the same id number displayed on the grid goes here>

I know it is possible to start with a hyperlink column, but since all of that is done and the thing is generated dynamically (no use of drag and drop datasets or dataviews or dataadapters), is there a way to change the property of the column to hyperlink and set it's hyperlink through code?

Thanks,
Brian
 
Visual Basic:
In the ItemTemplate of your grid place something like this...
'aspx file
<%# myFunction(DataBinder.Eval(Container.DataItem, "myColumnName")) %> 
 
'code behind file
Public Function myFunction(ByVal s As Object) As String
If IsDBNull(s) Then
Return ""
Else
Return s & "Something else here"
End If
End Function
 
Back
Top