?
Solved

DataGrid Conditional Hyperlink

Posted on 2011-04-27
6
Medium Priority
?
663 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:atljarman
5 Comments
 
LVL 9

Expert Comment

by:radcaesar
ID: 35477851
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
 

Author Comment

by:atljarman
ID: 35478176
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
 
LVL 7

Expert Comment

by:mr_nadger
ID: 35482024
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
 

Accepted Solution

by:
atljarman earned 0 total points
ID: 35482239
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 35865712
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Loops Section Overview

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question