How can I use Databound variables in conditional statements within Custom Databound controls?
- by William Calleja
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?