asp.net Repeater取得CheckBox选中的某行某个值的c#写法
程序员文章站
2023-03-13 23:35:22
1、 foreach (control c in this.rpttables.controls) { &n...
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;" />
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;" />