开发者

How to get Class propertyName to create lable?

how can i learn propert to create page form in asp.net


class MyClass
{
    public int id { get; set;}
    public string Name { get; set;}
    public string Name { get; set;}
}

ForExample : (To generate programmatically Asp.net 开发者_C百科forms)

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

But it is not run correctly:( loading is too slow... By the way i didn't create classıs in real time . i ama using linqtoSql . You can talk about solution wthi the base of linqtosql...


Have a look at Cache Reflection Results (Class Properties) and see if caching your reflection calls would help. As GenericTypeTea suggested, calling this multiple times is probably the cause of any delay you are seeing. Here is also a link to a Fast Reflection Library that may be a way to let someone else implement and debug the caching code for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜