开发者

Using Reflection to Bind Business Objects to ASP.NET Form Controls

开发者 https://www.devze.com 2023-04-07 10:43 出处:网络
This looks like a really useful way to simplify databinding ASP.NET controls to a generic business object. I\'ve yet to use this in a fully fledged开发者_StackOverflow中文版 live project and so

This looks like a really useful way to simplify databinding ASP.NET controls to a generic business object. I've yet to use this in a fully fledged开发者_StackOverflow中文版 live project and so

I'm not sure how accurate their performance metrics are. Off the top of my head I think I would implement these two methods 'BindControlsToObject' and 'BindObjectToControls' in a new class derived from the Page object, but whatever takes your fancy really.

How I can accurate their performance?


If performance is one of your concerns, then do not use reflection. At least not at every page call, so you could think about caching on demand or at application start.

You could bind to a list or an object without using reflection and this would enable you to use Eval("...") in the markup, which is a commonly used pattern and other programmers new to your project would become faster productive.

Besides this, doing this is a great way to learn reflection for something like a custom plugin system ( in the cases you cannot or do not want to use MEF or Unity or something like this ).

0

精彩评论

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