Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 静态asp:将所有复选标记评估为false的复选框列表_Asp.net_Checkboxlist_Aspx User Control - Fatal编程技术网

Asp.net 静态asp:将所有复选标记评估为false的复选框列表

Asp.net 静态asp:将所有复选标记评估为false的复选框列表,asp.net,checkboxlist,aspx-user-control,Asp.net,Checkboxlist,Aspx User Control,我的表单中有一个简单的静态复选框列表: <%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Groupes.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="WebApp.Form" %> <form runat="server"> <asp:Ch

我的表单中有一个简单的静态复选框列表:

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Groupes.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="WebApp.Form" %>
    <form runat="server">

          <asp:CheckBoxList ID="CheckBoxList1" runat="server" >
                    <asp:ListItem Text ="Text1" Value="1"  ></asp:ListItem>
                    <asp:ListItem Text ="Text2" Value="2" ></asp:ListItem>
                    <asp:ListItem Text ="Text3" Value="3" Selected="True" Enabled="false></asp:ListItem>
            </asp:CheckBoxList>
    </form>


一切正常,在我测试时工作正常。能否请您添加更多可能导致问题的相关代码。我在尝试获取所选列表项之前的另一个按钮单击事件上执行了CheckBoxList1.ClearSelection()。但即使这样,selectedValues.Count也始终返回1(只有表单中Selected设置为“True”的禁用ListItem才会被计数)
List<string> selectedValues = CheckBoxList1.Items.Cast<System.Web.UI.WebControls.ListItem>().Where(li => li.Selected).Select(li => li.Value).ToList();
<asp:ListItem Text ="Text3" Value="3" Selected="True" Enabled="false></asp:ListItem>