zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

asp.netRepeater取得CheckBox选中的某行某个值

ASP 某个 取得 选中 checkbox NETrepeater 某行
2023-06-13 09:14:01 时间
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 != null)
        {
            if (cbx.Checked)
            {
                common.salert(tbx.Text);
            }
        }
    }
}
关键点:在每行再写个隐藏的控件我是用TextBox,代码如下:
<asp:TextBox id="tbxTableName" runat="server" Text="<%#Eval("TABLE_NAME") %>" style="display:none;" />