I'm trying to style a table row based upon a value in the databound collection (from LINQ to SQL) in my item template, however it's not working.
This is what I have so far:
<ItemTemplate>
<%
string style = String.Empty;
if ((string)DataBinder.Eval(Quotes.Cu, "Status") == "Rejected")
style = "color:red;";
else if ((string)Eval("Priority") == "Y")
style = "color:green;";
if (style == String.Empty)
Response.Write("<tr>");
else
Response.Write("<tr style=\"" + style + "\"");
%>
<td>
<%# Eval("QuoteID") %>
</td>
<td>
<%# Eval("DateDue", "{0:dd/MM/yyyy}") %>
</td>
<td>
<%# Eval("Company") %>
</td>
<td>
<%# Eval("Estimator") %>
</td>
<td>
<%# Eval("Attachments") %>
</td>
<td>
<%# Eval("Employee") %>
</td>
</tr>
</ItemTemplate>
EDIT:
Sorry I didn't make this clearer! The problem is, It's throwing an error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.