Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.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
C# ASP.NET从Repeater获取所有复选框_C#_Html_Asp.net_Checkbox_Controls - Fatal编程技术网

C# ASP.NET从Repeater获取所有复选框

C# ASP.NET从Repeater获取所有复选框,c#,html,asp.net,checkbox,controls,C#,Html,Asp.net,Checkbox,Controls,我使用repeater在内容页中生成复选框 两个复选框都有一个唯一的ID 但是,复选框是通过循环字符串生成的 <input id=\"Checkbox" + i+ "-" + j + "\" type=\"checkbox\" name=\"CollapseID" + i + "\" /> 此外,我尝试: Control chk = FindControl("Checkbox1-1"); // where "Checkbox1-1" is the checkboxID 及 但也返

我使用repeater在内容页中生成复选框

两个复选框都有一个唯一的ID

但是,复选框是通过循环字符串生成的

<input id=\"Checkbox" + i+ "-" + j + "\" type=\"checkbox\" name=\"CollapseID" + i + "\" />
此外,我尝试:

Control chk = FindControl("Checkbox1-1"); // where "Checkbox1-1" is the checkboxID

但也返回空值


谢谢你的帮助

您应该在复选框中将属性写为
runat=“server”

然后


我想它会对您有用。

如果您使用字符串创建这些复选框,然后将它们作为HTML转储。它们将被视为html复选框,在服务器端无法访问。您只能在javascript中获得选中的复选框。。您可以将这些值分配给任何隐藏的服务器控件,然后在服务器端使用它。

是的,这似乎是我唯一的方法。。。谢谢。
Control chk = FindControl("Checkbox1-1"); // where "Checkbox1-1" is the checkboxID
HtmlInputCheckBox chk = (HtmlInputCheckBox)FindControl("Checkbox1-1");
CheckBox cx= repeaterName.FindControl("checkboxId") as CheckBox;