我有以下网格视图gvAgreement
和嵌套网格视图gvProducts
我希望在gvProducts
gvAgreement_RowCommand
我在gvProducts
gvAgreement_OnRowDataBound
通过以下代码
protected void gvAgreement_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
GridView gvProducts = e.Row.FindControl("gvProducts") as GridView;
}
protected void gvAgreement_RowCommand(object sender, GridViewCommandEventArgs e)
{
//your suggest code
}
答案 0 :(得分:1)
这将让您在父网格视图中找到任何子控件。
GridViewRow gvRow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
Int32 rowIndex = gvRow.RowIndex; // required if you want to find index of the control from where event has been raised.
GridView gvProducts = gvRow.FindControl("gvProducts") as GridView;