您的位置:首页 > 其它

动态添加自定义控件

2009-11-17 08:57 197 查看
<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);
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: