0
下面的内容应该很简单,但我是新手,所以我不知道如何在ASP.NET中快速执行此条件。在条件下显示列基础
基本上,我想显示复选框,如果Eval("CompanyID")
是NULL或什么都没有。
<asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyListPartialMatch">
<ItemTemplate>
<td style="width: 50px; border-right:1px solid black; border-spacing:0;"><%#Eval("Row")%></td>
<td style="width: 70%"><asp:Literal ID="litFoo" runat="server" Text='<%#Eval("Company")%>' /> </td>
<td style="width: 10%"><asp:Literal ID="Literal1" runat="server" Text='<%#Eval("CompanyID")%>' /> </td>
<td style="text-align:right;">
<asp:CheckBox id="check1" runat="server" />
</td>
<%-- Example: If (Eval("CompanyID") == "" Then Show this Below. Else, don't show it --%>
<td style="text-align:right;"><asp:CheckBox id="check1" runat="server" /></td>
<%-- END IF --%>
</ItemTemplate>
</asp:DataList>
当CompanyID为null时,将会抛出异常吗?Eval().ToString() – abatishchev
我更新了我的代码。 – Win
这实际上隐藏了复选框,但也隐藏了
你尝试
?
来源
2013-10-01 23:45:04 abatishchev
我得到这个错误,当我想你的代码:服务器标记不能包含<% ... %>结构。 – milacay
@milacay:你确定你<%=',没有其他人吗?请参阅http://stackoverflow.com/questions/1529944/why-cant-i-set-the-asplabel-text-property-by-calling-a-method-in-the-aspx-file – abatishchev
是的,我把确切您的建议代码并出现此错误:无法为其'Visible'属性的字符串表示'<%= Eval(“CompanyID”)!= null'创建类型为'System.Boolean'的对象。 – milacay
相关问题