我有财产
public bool AutoRenew
{
get;
set;
}
在页面中:
<input type="checkbox" checked='<%# Eval("AutoRenew") %>' />
但它总是被检查,即使属性的值为false
.
我尝试了以下变体:
<input type="checkbox" checked='<%# Convert.ToBoolean(Eval("AutoRenew")) %>' />
<input type="checkbox" checked='<%# Convert.ToBoolean(Eval("AutoRenew")) == true %>' />
<input type="checkbox" checked='<%# (Boolean)Eval("AutoRenew") %>' />
但没有任何效果,它一直在检查。表达式应该是什么样的?
编辑:这是页面中有问题的部分:
...
<asp:ListView ID="MyListView" runat="server">
<LayoutTemplate>
<table class="ms-listviewtable" style="background-color: White;">
<tr class="ms-viewheadertr ms-vhltr">
<th class="ms-vh-icon" scope="col">
<input type="checkbox" />
</th>
<th class="ms-vh2">
<div class="ms-vh-div"><a>Training Item</a></div>
</th>
<th class="ms-vh2">
<div class="ms-vh-div"><a>Training Task Type</a></div>
</th>
<th class="ms-vh2">
<div class="ms-vh-div"><a>Due Date</a></div>
</th>
<th class="ms-vh2">
<div class="ms-vh-div"><a>Auto-Renew</a></div>
</th>
<th class="ms-vh2">
<div class="ms-vh-div"><a>Training Reason</a></div>
</th>
</tr>
<tr id="itemplaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="ms-itmhover">
<td class="ms-vb-itmcbx ms-vb-firstCell">
<input type="checkbox" class="s4-itm-cbx" />
</td>
<td class="ms-vb-title">
<div class="ms-vb itx"><a><%# Eval("Title")%></a></div>
</td>
<td class="ms-vb2">
<asp:DropDownList ID="TaskTypeDropDownList" runat="server">
</asp:DropDownList>
</td>
<td class="ms-vb2"><%# Eval("DueDate")%></td>
<td class="ms-vb2" style="text-align: center;">
<input type="checkbox" checked='<%# Convert.ToBoolean(Eval("AutoRenew")) %>' />
</td>
<td class="ms-vb2"><%# Eval("TrainingReason")%></td>
</tr>
</ItemTemplate>
...