在gridview

时间:2016-06-13 09:51:27

标签: asp.net gridview

如何在同一gridview中检索gridview中的asp CheckBox ID?现在,它说的是名称不在当前的背景下

1 个答案:

答案 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");
                        }
                    }
                }
            }
        }