IpInterfaceUC 用户控件:
<div id="dvChannel" runat="server" style="height: 205px; width: 550px; overflow: auto;
margin-left: 5px;">
<asp:GridView ID="gvChannelUC">
</div>
初始化的代码隐藏
int indexInterface=0;
foreach (DataRow row in dtDevicesListByRole.Rows)
{
ctrIpInterfaceUC = (Test2.SetupGroup.Ipservice.IpInterfaceUC)LoadControl("IpInterfaceUC.ascx");
Control ctr = (Control)ctrIpInterfaceUC;
ctr.ID = "device_"+ip+"_"+port+"$"+indexInterface;
phDevices.Controls.Add(ctr);//PlaceHolder for add many UserControl
}
显示
<div id="dvChannel">
<div id="device_192.168.2.19_3331_0_pnlChannelUC">
<div id="device_192.168.2.19_3331_0_dvChannel">
<table id="device_192.168.2.19_3331_0_gvChannelUC">
</table>
</div>
</div>
<div id="dvChannel">
<div id="device_192.168.2.19_3331_1_pnlChannelUC">
<div id="device_192.168.2.19_3331_1_dvChannel">
<table id="device_192.168.2.19_3331_1_gvChannelUC">
</table>
</div>
</div>
问题 如何从多个 UserControl 中获取 gridview?