我试图根据我的项目模板中的数据绑定集合(从LINQ到SQL)中的值设置表格行的样式,但它不起作用。ASP.NET Repeater - 将项目评估为int?
这是我到目前为止有:
<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>
编辑:
对不起,我没有说明清楚!问题是,这是抛出一个错误:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
对不起,这行不工作
通知? – 2010-04-16 20:12:26