我正在使用嵌套用户控件....
喜欢:我有一个'A'用户控件,其中包含网格视图,然后是'B'用户控件,其中包含'A'和另一个用户控件,然后是'C'用户控件包含'B'和另外2个用户控制...
我想在'C'用户控件
中使用row命令提前致谢
答案 0 :(得分:0)
您可以通过以下两种方式实现这一目标。
在A控件中公开具有公共属性的网格视图。在B控件中,将A控件公开为公共属性。所以在你的C控件中你可以编写像
这样的东西bControl.aControl.GridProperty.OnRowCommand += youreventhandler;
或者您可以在A控件上定义事件,例如OnInnerGridRowCommand,并在RowCommand发生时将此事件提升为B控件。在B控件中定义另一个事件,并在A的OnInnerGridRowCommand发生时使用适当的参数引发此新事件。所以你可以在控件C中处理这个新事件。
<小时/> 这是C用户控件暴露内部网格
public GridView GridView_In_C
{
get { return innerGrid; }
}
这是B用户控件暴露C
public CWebUserControl C_In_B
{
get
{
return CWebUserControl_In_B;
}
}
这是一个暴露B的用户控件
public BWebUserControl B_In_A
{
get
{
return BWebUserControl_In_A;
}
}
这是一个托管用户控件并附加到RowCommand的页面,
public partial class HostPage : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
AWebUserControlInHostPage.B_In_A.C_In_B.GridView_In_C.RowCommand += new GridViewCommandEventHandler(InnerGridView_RowCommand);
}
void InnerGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
}