【发布时间】:2011-03-10 03:54:10
【问题描述】:
我如何学习在 asp.net 中创建页面表单的属性
class MyClass
{
public int id { get; set;}
public string Name { get; set;}
public string Name { get; set;}
}
ForExample :(以编程方式生成 Asp.net 表单)
void SetRecursiveTextBoxAndLabels()
{
Label lbl;
MyClass eng = new MyClass();
Type typ = eng.GetType();
PropertyInfo[] properties = typ.GetProperties();
for( int i =0; i<properties.Length; i++)
{
lbl = new Label();
lbl.ID = properties[i].Name;
lbl.Text = properties[i].Name;
PlaceHolder1.Controls.Add(lbl);
}
}
}
但它运行不正确:(加载太慢了...顺便说一句,我没有实时创建类。我正在使用 linqtoSql 。您可以谈论基于 linqtosql 的解决方案...
【问题讨论】:
-
您提供的代码应该运行得比较快。你给我们提供了一个缩短的版本吗? SetRecursiveTextBoxAndLabels() 会被多次调用吗?
标签: c# .net asp.net visual-studio-2008