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

atljarmanAsked:
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.
0
 
radcaesarCommented:
Dim HL1 As New HyperLink()
    HL1.Visible = True
    HL1.ID = "HL1"
    if(condition........)
    HL1.NavigateUrl = "http://asp.net"
    End If
    HL1.Text = "Yahoo"
    gdvAttd.Rows(0).Cells(0).Controls.Add(HL1)
0
 
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?  
0
 
mr_nadgerCommented:
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
0
 
DhaestCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
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.