动态添加自定义控件
<asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>
string sql= "select Id,Name from Class where ParentId=0";
DataSet ds = help.Query(sql);
if (ds != null)
{
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
for (var i = 0; i < dt.Rows.Count; i++)
{
Control trol = LoadControl("Class.ascx");
Type atype = trol .GetType();
System.Reflection.PropertyInfo dd = atype.GetProperty("BigId");
dd.SetValue(trol , dt.Rows[i]["Id"], null);
ph.Controls.Add(trol);
}
}
}