IpInterfaceUC UserControl:
Expose the gridview through a public property on your UserControl:
public GridView Grid
{
get { return gvChannelUC; }
}
Then
List<string, string> Grids = new List<string, string>(); // <UCId, GridId>
...
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
...
While you can recursively use FindControl to find it, a much better approach is to let the UserControl IpInterfaceUC
decide how to bind data to the controls within it.
You could add a public method ShowData
to you UserControl and pass the data to be displayed to it. It can then assign it to gvChannelUC
.
int indexInterface=0;
foreach (DataRow row in dtDevicesListByRole.Rows)
{
var ctrIpInterfaceUC = (Test2.SetupGroup.Ipservice.IpInterfaceUC)LoadControl("IpInterfaceUC.ascx");
ctrIpInterfaceUC.ShowData(myRows);
ctrIpInterfaceUC.ID = "device_"+ip+"_"+port+"$"+indexInterface;
phDevices.Controls.Add(ctrIpInterfaceUC);//PlaceHolder for add many UserControl
}