asp.net Repeater取得CheckBox选中的某行某个值的c#写法
时间:2021-07-01 10:21:17
帮助过:58人阅读
1、
foreach (Control c in this.rptTables.Controls)
{
CheckBox cbx = (CheckBox)c.FindControl("cbxId");
TextBox tbx = (TextBox)c.FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked == true)
{
common.salert(tbx.Text);
}
}
}
2、
for (int i = 0; i < this.rptTables.Items.Count; i++)
{
CheckBox cbx = (CheckBox)rptTables.Items[i].FindControl("cbxId");
TextBox tbx = (TextBox)rptTables.Items[i].FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked)
{
common.salert(tbx.Text);
}
}
}
关键点:在每行再写个隐藏的控件我是用TextBox,代码如下:
<asp:TextBox id="tbxTableName" runat="server" Text='<%#Eval("TABLE_NAME") %>' style="display:none;" />