I get a good string value from the following Data-Binding expression in a ASP.NET Web Forms ascx control:
<%# ((MyCompany.CoreLib.Main.ChallengeQuestion)Container.DataItem).AnswerType %>
I want to do something like:
<EditItemTemplate>
<% if (%>
<%# ((MyCompany.CoreLib.Main.ChallengeQuestion)Container.DataItem).AnswerType %>
<% == "DateTime") { %>
Show this text
<% ; } else { %>
Show this other text
<% ; } %>
<EditItemTemplate>
Is something like this possible?
That's not possible but you could define a method on the code behind and use it on the aspx
CODE BEHIND
public string GetAnswerTypeText(MyCompany.CoreLib.Main.ChallengeQuestion challengeQuestion)
{
if (challengeQuestion.AnswerType.Equals("DateTime"))
{
return "some text";
}
else
{
return "some other text";
}
}
ASPX
<%# GetAnswerTypeText((MyCompany.CoreLib.Main.ChallengeQuestion)Container.DataItem) %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.