动态添加自定义控件
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);
}
}
}
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);
}
}
}
相关文章推荐
- ASP.NET 动态添加自定义控件
- C#在控件上有序地动态添加自定义控件
- 动态添加自定义控件:即按一下Botton添加一个UseControl,再按一下又添加一个
- WPF--自定义控件的动态添加以及BackgroundWorker的使用
- 关于动态添加自定义控件的使用心得
- 关于动态添加的自定义控件的问题
- 笔记98--自定义控件示例1:仿小米添加联系人(动态改变行数)
- ToolStrip动态添加自定义控件
- datagrid 动态添加自定义控件方法!
- 疑问:AddWebPart 不能添加动态加载的自定义控件吗?
- ASP.NET 动态添加自定义控件
- jquery动态添加删除div--事件绑定,对象克隆
- C# winform 动态添加控件 以及 事件
- jQuery -- 如何为动态添加的元素绑定事件处理函数
- jQuery动态添加<input type="file">
- .Net 点击按钮实现动态添加行并保持页面的数据不变
- JavaScript实现页面动态添加图片
- vue.js 利用SocketCluster实现动态添加数据及排序
- js中为什么不能为值类型的变量动态添加属性呢?
- activiti中多实例任务中动态添加用户ID、删除用户、委派