如果对象的 CRMID 是一个可以为空的字符串,我只想显示某个项目模板。
如果它是 null 我不想显示这个项目模板:
<asp:TemplateField HeaderText="">
<ItemTemplate>
<a href="#myModal" id='rm_btn' runat="server" role="button" class="close custom-close" onclick="showModal('#myModal')" onserverclick="rmbtn"
visible='<%# (bool)(DataBinder.Eval(Container.DataItem, "CRMID") == null) ? "true" : "false" %>'>
×</a>
</ItemTemplate>
</asp:TemplateField>
但是我收到以下错误:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0030: Cannot convert type 'string' to 'bool'
Source Error:
Line 136: <asp:TemplateField HeaderText="">
Line 137: <ItemTemplate>
Line 138: <a href="#myModal" id='rm_btn' runat="server" role="button" class="close custom-close" onclick="showModal('#myModal')" onserverclick="rmbtn"
Line 139: visible='<%# (bool)(DataBinder.Eval(Container.DataItem, "CRMID") == null) ? "true" : "false" %>'>
Line 140: ×</a>
我不确定我做错了什么......
谢谢