如果Listview中的语句不起作用. [英] If statement inside Listview is not working.
本文介绍了如果Listview中的语句不起作用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我正在尝试在Listview中添加if语句.这是我的代码.
<% if (Eval( 正确")== ){%>
< asp:LinkButton ID =" runat 服务器" 文本 删除" CommandName 删除" / >
<%} %>
它显示此错误. 诸如Eval(),XPath()和Bind()之类的数据绑定方法只能在数据绑定控件的上下文中使用".请帮助我解决此问题.
预先表示感谢.
解决方案
Eval()仅可用于诸如中继器或datagrid之类的控件中以绑定数据.而是在服务器端使用属性,并在适当的地方设置其值,然后在aspx或ascx中使用它.
例如
受保护的 int 正确;
//在适当的地方进行分配
正确= 0 ;
在ascx或aspx
中
<![CDATA [<%if(正确== 0 )) {%> ]] > < asp:linkbutton id = " runat = " text = " commandname = " xmlns:asp = " /> <![CDATA [&%; } %> ]] >
>
Hi all
I am trying to add if statement inside Listview. This is my code.
<% if (Eval("Correct") == "0") { %>
<asp:LinkButton ID="btnZnackyDelete" runat="server" Text="delete" CommandName="Delete" />
<% } %>
It is showing This error. "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control". Please help me to fix this Problem.
Thanks in advance.
解决方案
Eval() can only be used in controls such as repeater or datagrid to bind data. Rather use a property on server side and where appropriate sets its value and use it in your aspx or ascx.
e.g
protected int Correct;
// Assignment made where appropriate
Correct = 0;
in ascx or aspx
<![CDATA[<%if (Correct == 0) {%>]]> <asp:linkbutton id="btnZnackyDelete" runat="server" text="delete" commandname="Delete" xmlns:asp="#unknown" /> <![CDATA[<% }%>]]>
这篇关于如果Listview中的语句不起作用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文