I would like to run an if statement but the condition uses a variable from the code behind. How do I call that variable? Side note… I am using a gridview and the variable is in a dataset (dsResult – idnbr colum)
<ItemTemplate>
<% string temp = (Eval("idnbr").ToString());
if (temp.Contains("X")) { %>
<asp:Label ID="Label1" runat="server" Text='<%# (Eval("old_amt").ToString(),"ccTot") %>'></asp:Label>
<% } else { %>
<asp:Label ID="Label2" runat="server" Text='<%# (Eval("new_amt").ToString(),"ccTot") %>'></asp:Label>
<% } %>
</ItemTemplate>
Create c# side method that does it for you:
Than use one of 2 ways:
can just cast it to your entity and pass back:
C#:
ASP.Net:
Second case – just use eval syntax
C#:
ASP.Net:
(,