asp.net – 使用内联代码测试Container.DataItem
发布时间:2020-12-16 03:52:37 所属栏目:asp.Net 来源:网络整理
导读:我想在ASP.Net 2.0中做这样的事情: asp:Repeater id="myRepeater" runat="server" ItemTemplate % if (DataBinder.Eval(Container.DataItem,"MyProperty").Equals("SomeValue")) { % %#DataBinder.Eval(Container.DataItem,"MyProperty")% % } % /ItemTempl
我想在ASP.Net 2.0中做这样的事情:
<asp:Repeater id="myRepeater" runat="server"> <ItemTemplate> <% if (DataBinder.Eval(Container.DataItem,"MyProperty").Equals("SomeValue")) { %> <%#DataBinder.Eval(Container.DataItem,"MyProperty")%> <% } %> </ItemTemplate> </asp:Repeater> 但我不能像这样测试DataBinder.Eval(Container.DataItem,“MyProperty”). 注意:我无法访问源代码,我只能更改内联的aspx. NOTE2:我知道我可以用这个: <%#DataBinder.Eval(Container.DataItem,"MyProperty").Equals("SomeValue")?"<!--":""%> 但我一直在寻找一种更清洁的方式. 有没有办法在Repeater中使用内联代码测试Container.DataItem? 解决方法
我会这样做的.您将“visibility”函数绑定到asp:literal控件的visible属性:
<asp:Repeater id="myRepeater" runat="server"> <ItemTemplate> <asp:literal runat='server' id='mycontrol' visible='<%# DataBinder.Eval(Container.DataItem,"MyProperty").Equals("SomeValue") %>'> <%# DataBinder.Eval(Container.DataItem,"MyProperty") %> </asp:literal> </ItemTemplate> </asp:Repeater> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 为什么在VS2008 / Casini中开始调试时Applicati
- 带有声明性数据的Eval绑定ASP.NET
- asp.net – ReportViewer超时,尽管超时设置
- asp.net – 使用jQuery调用MVC中的action方法,参数不起作用
- 如何在asp.net和C#中实现登录会话
- asp.net-mvc – 特定便携式区域的ControllerFactory
- asp.net-mvc – 每个请求DbContext发生随机错误
- asp.net-mvc-4 – Asp.Net MVC 4 bundle不提供section属性?
- Parallel线程安全问题
- asp.net-mvc – 会话超时处理的会话开始和操作过滤器
推荐文章
站长推荐
- asp.net-core-mvc – “:exists”在路由模板上做
- asp.net – 可接受的安全性:使用Paramatised SQ
- asp.net-mvc – 如何asp.net(mvc)服务器返回错误
- asp.net-mvc-4 – 使用web.config中的凭据设置配
- asp.net-mvc-3 – 模型binder属性类型int的问题
- asp.net – 用于存储表单字段和字段值的数据库架
- asp.net-core – ASP.NET vNext – 本地化(.resx
- asp.net – “无法启动IIS Express Web服务器”错
- asp.net – System.Web.HttpException:请求超时
- asp.net-mvc – Telerik MVC网格大师详细级联下拉
热点阅读