Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

动态添加自定义控件

<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);
                }
              
            }
        } 

posted @ 2009-11-17 08:57  cn2024  阅读(147)  评论(0编辑  收藏  举报