Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 嵌套UserControl中的GridView事件_Asp.net_C# 4.0 - Fatal编程技术网

Asp.net 嵌套UserControl中的GridView事件

Asp.net 嵌套UserControl中的GridView事件,asp.net,c#-4.0,Asp.net,C# 4.0,我正在使用嵌套的用户控件 比如:我有一个包含网格视图的“a”用户控件,然后是一个包含“a”和一个以上用户控件的“B”用户控件,然后是一个包含“B”和两个以上用户控件的“C”用户控件 我需要“C”用户控件中的row命令 提前感谢这里有两种方法可以实现这一点 在控件中公开具有公共属性的网格视图。在B控件中,将A控件作为公共属性公开。因此,在C控件中,可以编写如下内容 bControl.aControl.GridProperty.OnRowCommand += youreventhandler; 或

我正在使用嵌套的用户控件

比如:我有一个包含网格视图的“a”用户控件,然后是一个包含“a”和一个以上用户控件的“B”用户控件,然后是一个包含“B”和两个以上用户控件的“C”用户控件

我需要“C”用户控件中的row命令


提前感谢

这里有两种方法可以实现这一点

在控件中公开具有公共属性的网格视图。在B控件中,将A控件作为公共属性公开。因此,在C控件中,可以编写如下内容

bControl.aControl.GridProperty.OnRowCommand += youreventhandler;
或者,您可以在控件上定义事件,例如OnInnerGridRowCommand,并在RowCommand发生时将此事件提升到B控件。在B控件中定义另一个事件,并在发生A的OnInnergridRow命令时使用适当的参数引发此新事件。所以您可以在控件C中处理这个新事件。
这是公开内部网格的C用户控件

public GridView GridView_In_C
{
    get { return innerGrid; }
}
这是B用户控件C

public CWebUserControl C_In_B
{
    get
    {
        return CWebUserControl_In_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)
    {

    }
}

谢谢……但我无法理解in=>bControl.aControl.GridProperty.OnRowCommand+=youreventhandler;什么是B控制和A控制…它们是公共财产…还是。。??????