DataGrid Conditional Hyperlink

I have one form that I use to delete, edit, advanced edit, and restore.  I hide the columns based on the url variable value.  Since this form accesses several different folders, the hyperlink to the different files (e.g., images, documents) does not work.  I was wondering if I could conditionally add the DataTextFieldFormat and change it also based on the URL.

Maybe this is simpler than I am thinking, but I am not sure if this is an in page edit or a VB script edit.
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="Name" />

Open in new window

Who is Participating?
atljarmanConnect With a Mentor Author Commented:
Thanks.  What I ended up doing was adding a separate column and hiding (.visible = false) the columns that did not apply to the page.
Dim HL1 As New HyperLink()
    HL1.Visible = True
    HL1.ID = "HL1"
    HL1.NavigateUrl = ""
    End If
    HL1.Text = "Yahoo"
atljarmanAuthor Commented:
This is a great suggestion.  I do use the name of the file in the row.  So for example

Images:  HL1.NavigateURL = "images\{0}"
Documents:  HL1.NavigateURL = "documents\{0}"
Backups:  HL1.NavigateURL = "bkup\{0}"
Pages:  HL1.NavigateURL = "{0}"

I'm not sure if the Dim suggested will account for the row variable.  Also, do you then put this under the Page_Load sub?  
You've got this in a gridview?
Put the hyperlink in a template field, and the values which will determine the style and text of your link in as datakeys for the gridview, then iterate through the rows on the databound event to amend each row's link accordingly
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.