页面<!--测试-->
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked=<%# Eval("CHK").ToString()=="1"?true:false %> /><asp:TextBox
ID="TextBox1" runat="server" Text=<%# Eval("PopedomName") %>></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
<!--测试-->
绑定: Repeater1.DataSource = DS.Tables[0];
Repeater1.DataBind();
其中的CHK为标志位,可以为任何数据。
或者是手动添加一个标志。
其中获取结果为: protected void Button5_Click(object sender, EventArgs e)
{
string ss = "";
foreach (Control c in this.Repeater1.Controls)
{
CheckBox cbx = (CheckBox)c.FindControl("CheckBox1");
TextBox tbx = (TextBox)c.FindControl("TextBox1");
if (cbx != null)
{
if (cbx.Checked == true)
{
ss += tbx.Text;
}
}
}
}
要一个隐藏的服务器控件。
参考网上代码,然后又自己根据情况所写。