How can I use Databound variables in conditional statements within Custom Databound controls?
Posted
by William Calleja
on Stack Overflow
See other posts from Stack Overflow
or by William Calleja
Published on 2010-03-18T12:28:15Z
Indexed on
2010/03/18
12:31 UTC
Read the original article
Hit count: 387
I'm developing my custom DataBound Controls that make use of an '<ItemTemplate>
' tag and '<%# %>
' server tags to generate some data however I need to make a conditional statement within one of my Databound controls as shown below.
<custom:DataboundControl runat="server">
<ItemTemplate>
<% if(((Dictionary<string, string>)Container.DataItem)["MyVariable"]=="" { %>
<!-- Conditional Code Happens Here -->
<% } %>
</ItemTemplate>
</custom:DataboundControl>
Right now my code isn't working because the compiler cannot recognize my Container.DataItem
variable within a <% %>
tag and a <%# %>
tag doesn't support conditional statements. What can I use?
© Stack Overflow or respective owner