I have a repeater showing product stocks. I want show if no stock "Out of stock". If present show stock amount and unit.
I tried the following ways:
<%#Convert.ToInt32(Eval("AMOUNT")) == 0 ? "Out of stock" : %><%#Eval("AMOUNT") %> <%#Eval("UNIT") %>
and
<% if ( Convert.ToInt32(Eval("AMOUNT")) == 0) { %>
<asp:Label ID="Label1" runat="server" Text='Out of stock'></asp:Label>
<%} else { %>
<asp:Label ID="Label2" runat="server" Text='<%#Eval("AMOUNT") %>'></asp:Label>
<% } %>
I am getting this error in this method: System.InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Maybe there is a simple solution but I can't find. Thanks.