AlexW
AlexW

Reputation: 2587

using eval for a int not a control, or what do i use instead of eval?

I pass some datarow fields multiple times in a few functions to get some result for my table, so i thought id put them in some int's make the code clean, but the below returns

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. 

and if i use <%# instead i get expected ")" (right bracket)

what do i need to use to make the below work?

Thanks

<%
    C = Convert.ToInt32(Eval("Confidentiality"));
    I = Convert.ToInt32(Eval("Integrity"));
    A = Convert.ToInt32(Eval("Availability"));
    T = Convert.ToInt32(Eval("Threat"));
    V = Convert.ToInt32(Eval("Vulnerability"));
    L = Convert.ToInt32(Eval("Likelihood"));
%>

<td class='<%# functions.colorscale(functions.Importance(C,I,A))%>'><%# functions.Importance(C,I,A) %></td>
<td class='<%# functions.colorscale(functions.Rank(C,I,A,T,V,L))%>'><%# functions.Rank(C,I,A,T,V,L) %></td>
<td class='<%# functions.colorscale(Eval("NewRank").ToString())%>'><%# Eval("NewRank") %></td>

Upvotes: 1

Views: 172

Answers (1)

AlexW
AlexW

Reputation: 2587

i needed to put each var in its own <% now it works!

            <%# C = Convert.ToInt32(Eval("Confidentiality")) %>
            <%# I = Convert.ToInt32(Eval("Integrity")) %>
            <%# A = Convert.ToInt32(Eval("Availability")) %>
            <%# T = Convert.ToInt32(Eval("Threat")) %>
            <%# V = Convert.ToInt32(Eval("Vulnerability")) %>
            <%# L = Convert.ToInt32(Eval("Likelihood")) %>

Upvotes: 1

Related Questions