Get GridView in Multiple UserControl from codebehind

后端 未结 2 1848
遥遥无期
遥遥无期 2021-01-26 18:31

IpInterfaceUC UserControl:

2条回答
  •  情深已故
    2021-01-26 19:10

    Expose the gridview through a public property on your UserControl:

    public GridView Grid
    {
      get { return gvChannelUC; }
    }
    

    Then

    List Grids = new List(); // 
    ...
    ctrIpInterfaceUC = (Test2.SetupGroup.Ipservice.IpInterfaceUC)LoadControl("IpInterfaceUC.ascx");
    string Id = "device_"+ip+"_"+port+"$"+indexInterface;
    
    GridView ctrGridView = ctrIpInterfaceUC.Grid;
    Grids.Add(Id, ctrGridView.ClientID);
    
    Control ctr = (Control)ctrIpInterfaceUC;
    ctr.ID = Id
    phDevices.Controls.Add(ctr);//PlaceHolder for add many UserControl
    ...
    

提交回复
热议问题