如何在同一gridview中检索gridview中的asp CheckBox ID?现在,它说的是名称不在当前的背景下
答案 0 :(得分:0)
如果您想在RowDataBound
事件中检索
protected void gvFirstGridView(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gvSecondGridView = e.Row.FindControl("2ndGV") as GridView;
CheckBox c = (CheckBox)gvSecondGridView.FindControl("2ndGVCheckbox);
}
}
其他Button
点击
foreach (GridViewRow row in gvFirstGridView.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
GridView gvChild = (GridView)row.FindControl("2ndGV");
if (gvChild != null)
{
foreach (GridViewRow childRow in gvChild.Rows)
{
if (childRow.RowType == DataControlRowType.DataRow)
{
CheckBox chk = (CheckBox)childRow.FindControl("2ndGVCheckbox");
}
}
}
}
}