DataList控件,条件语句上述<&ItemTemplate中GT ;? [英] DataList, Conditional statements in <ItemTemplate>?

查看:102
本文介绍了DataList控件,条件语句上述<&ItemTemplate中GT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做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.

RowDataBound事件从MSDN

这篇关于DataList控件,条件语句上述&lt;&ItemTemplate中GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆