Reputation: 171
This below should be simple, but I am new so I don't know how to do this condition on the fly with ASP.NET.
Basically, I want to show the checkboxes if Eval("CompanyID")
is NULL or nothing.
<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>
Upvotes: 0
Views: 468
Reputation: 62290
You can use CSS to hide the column.
<td style="text-align: right; <%# (Eval("CompanyID") == null || Eval("CompanyID").ToString() == "") ? "": "display: none" %>">
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
Hide only CheckBox
<td style="text-align: right;">
<div style="<%# (Eval("CompanyID") == null || Eval("CompanyID").ToString() == "") ? "": "display: none" %>">
<asp:CheckBox ID="CheckBox1" runat="server" />
</div>
</td>
Upvotes: 0
Reputation: 100308
Did you try
<asp:CheckBox Visible='<%= Eval("CompanyID") != null ' />
?
Upvotes: 1