DataList控件,条件语句上述&lt;&ItemTemplate中GT ;? [英] DataList, Conditional statements in <ItemTemplate>?
问题描述
我试图做ASP.NET 3.5以下。基本上,我绑定的LinqDataSource到一个DataList。有一个名为删除的属性,如果这是真的,我想显示不同的标记。下面code抛出错误:
I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called "Deleted" and if it is true, I want to display different markup. The following code throws errors:
<asp:DataList runat="server">
<ItemTemplate>
<% If CBool(Eval("Deleted")) Then%>
...
<% Else%>
...
<% End If%>
</ItemTemplate>
</asp:DataList>
这可能吗?如果不是,有什么办法?
Is this possible? If not, what are the alternatives?
推荐答案
为什么不直接使用RowDataBound事件并检查您的字段的值呢?的RowDataBound是理想的,你想根据结果集中的值来改变一个GridView数据这些情况。
Why not just use the RowDataBound event and check the value of your fields then? RowDatabound is ideal for these situations where you want to alter data in a gridview based on values in the result set.
这篇关于DataList控件,条件语句上述&lt;&ItemTemplate中GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!