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
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