Si8
Si8

Reputation: 9225

How to replace a query string in ASP.net

I have the following line:

<li><%# Eval("Gender").ToString() %></li>

which displays the gender of a person:

M

OR

F

How can I modify so, if it's M, it will display MALE and if it's F, it will display FEMALE?

Upvotes: 0

Views: 81

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460058

You could use the conditional operator

<li><%# (String)Eval("Gender") == "M" ? "MALE" : "FEMALE" %></li>

Upvotes: 5

Related Questions