使用复选框检索ASP中数据网格中的多个数据项.NET C#
本文关键字:数据项 NET 网格 数据网 复选框 检索 ASP 数据 | 更新日期: 2023-09-27 17:58:56
protected void Button1_Click(object sender, EventArgs e)
{
foreach (DataGridItem di in GridView1.Items)
{
HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
if (chkBx != null && chkBx.Checked)
{
//What should I write to get the Items of that checked row.
}
}
}
帮助我如何检索每个选中行的行项目。
我试过这样做,但它没有在标签上添加任何内容
foreach (GridViewRow di in GridView1.Rows)
{
HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
if ( chkBx != null && chkBx.Checked)
{
FID[j] += di.Cells[2].Text;
j++;
Label1.Text += di.Cells[2].Text;
}
}
它应该是Rows
而不是Items
foreach (GridViewRow di in GridView1.Rows)
{
HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
if (chkBx != null && chkBx.Checked)
{
//What should I write to get the Items of that checked row.
}
}