[英]Compiler Error Message: CS0103: The name 'Bind' does not exist in the current context
I'm having a problem accessing a property that I want to use as a condition on whether or not to display a particular element 我在访问要用作是否显示特定元素的条件的属性时遇到问题
<%if( (int)(Bind("DefaultAddress.AddressType"))==1)
{
%>
<td>
.....
....
</td>
<% }%>
This gives: 这给出:
Compiler Error Message: CS0103: The name 'Bind' does not exist in the current context 编译器错误消息:CS0103:名称“绑定”在当前上下文中不存在
However elsewhere on the same .aspx page I have: 但是在同一.aspx页上的其他地方,我有:
<td class="return" align="left">
<asp:Label ID="Label9" Text='<%# Bind("DefaultAddress.Country") %>' runat="server" />
</td>
which works perfectly. 完美地运作。 Note DefualtAddress is an instance of an Address object and Country and AddressType are properties of this object 注意DefualtAddress是一个Address对象的实例,Country和AddressType是此对象的属性
I also tried 我也试过
<% if (DefaultAddress.AddressType==1)
but with the above code DefaultAddress is highlighted in red and when I hover over it I get the error message: Cannot resolve symbol 'DefaultAddress' 但是上面的代码DefaultAddress用红色突出显示,当我将鼠标悬停在上面时,收到错误消息:无法解析符号'DefaultAddress'
如果我没记错的话, Bind
只能与<%#
标记一起使用。(WebForms对我来说很久以前...)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.