Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Moderators
Posted
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

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...