相关疑难解决方法(0)

设置Eval(bool)的选中值

我有一个房产

public bool AutoRenew
{
    get;
    set;
}
Run Code Online (Sandbox Code Playgroud)

在页面中:

<input type="checkbox" checked='<%# Eval("AutoRenew") %>' />
Run Code Online (Sandbox Code Playgroud)

但总是检查,即使属性的值是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") %>' />
Run Code Online (Sandbox Code Playgroud)

但没有任何作用,它一直在检查.表达式应该是什么样的?

编辑:这是页面中有问题的部分:

...
<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> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net checkbox

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1

checkbox ×1