Avatar of poultarp
poultarp
 asked on

ASP.NET C#: Dynamic text in GridView HyperLinkField

Hello All

I have a GridView on an ASP.NET C# website that contains data from a database. In the GridView I have a HyperLinkField.

What I want to do is change the text of the HyperLinkField depending on the value of one of the GridView Columns (if the column is 0 the HyperLinkField text should be "Activate" and if the value is 1 the text should be "Block").

Does anyone know how this can be done?

Regards
Søren Augustesen
.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
markmiddlemist

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
markmiddlemist

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rajvja

Hi

you can use this

Text='<%# Eval("colname")%> == "1" ? "Yes" : "No"

this is just example
poultarp

ASKER
Hello Mark

Thank you for your answer.

I have one quick question:

In the <%Eval %> line, how do I pass more than one value to the URL parameters?

Regards
Søren Augustesen
SOLUTION
markmiddlemist

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
poultarp

ASKER
Thank you Mark - it works just as I want it to!

Regards
Søren Augsutesen
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
markmiddlemist

Glad to help. It's a very useful technique, and one I use almost daily.