late-bound data binding 的妙处

March 28th, 2005

搞定 支持 aspx 语法的 Template 引擎 后即开始编写 template以及试验从 windows forms 程序传递数据。在我的设计标准中,数据结构 Custom Object 有先于 DataSet,一般尽量避免 late-bound data binding:
< %#="" databinder.eval(container,="" "dataitem.title")="" %="">
而是建议 bind to cutom object:
< %#="" ((wbeditor.post)="" container.dataitem).title="" %="">‘>

asp.net web 系统是应该这么做的,但是用在 Template 引擎 中有个问题:asp.net host 固定要到 bin 目录下去找包含 WBEditor.Post 类定义的 DLL。从程序发布 (depolyment) 的观点来看,不是很舒服的结构。这种情况下 late-bound data binding 就很有用了。它不要依赖于 DLL,而是在 run-time 通过 reflection 去取值。

有趣的是 DataBinder.Eval 不仅仅能对付 Container.DataItem,还能用在 object 上。< %#="" databinder.eval(post,="" "createddate",="" "d")="" %="">

Entry Filed under: Programming

1 Comment Add your own

  • 1. andri  |  March 3rd, 2006 at 7:31 pm

    Man, you need blogging more. Why not show your blog on the http://www.wbeditor.com website? It’s more convincing that you show customers that you have a blog since you’re the programer of wbeditor. It’s a good and convinent way to communicate with your customers.

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

Most Recent Posts


1