Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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.net - Fatal编程技术网

Asp.net 如何通过动态添加的复选框检索值

Asp.net 如何通过动态添加的复选框检索值,asp.net,Asp.net,下面是动态添加复选框的HTML代码 <asp:Panel ID="Panel1" runat="server"> <asp:Label ID="Label1" runat="server" Text="Text Catogaries"></asp:Label> <br /> <br /> <br /> <asp:Repeater ID="Repeater1" runat="server"&g

下面是动态添加复选框的HTML代码

 <asp:Panel ID="Panel1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="Text Catogaries"></asp:Label>
<br />

<br />
    <br />
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate >

        <table>
      <td>
            <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# Eval("CategoryName") %>'/>
            </td>
           </table>

        </ItemTemplate>

    </asp:Repeater>
    <br />
  <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    <br />
    <br />
</asp:Panel>

问题是,若我在列表中添加值,那个么控件将不运行。如何在列表中添加值

使用下面的代码从repeater中查找复选框

foreach (RepeaterItem item in Repeater1.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var checkBox1 = item.FindControl("CheckBox1") as CheckBox;
                    if (checkBox1 != null)
                    {
                        // Process further
                    }
                }
            }
foreach (RepeaterItem item in Repeater1.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var checkBox1 = item.FindControl("CheckBox1") as CheckBox;
                    if (checkBox1 != null)
                    {
                        // Process further
                    }
                }
            }