Databinder.Eval 和 Container.DataItem 有什么区别? [英] What's the difference between Databinder.Eval and Container.DataItem?
问题描述
当您使用 asp.net 数据绑定表达式时:
When you're using asp.net databinding expressions:
<asp:Label Text='EXPRESSION' runat="server" />
有什么区别:
Container.DataItem("Property")
和
Databinder.Eval(Container.DataItem, "Property")
和
Eval("Property")
和
Bind("Property")
推荐答案
Eval
是单向绑定,Bind
是双向绑定.使用 Eval
允许您将内容放入您的页面,但 ASP.Net 将无法为您将其放回对象中.
Eval
is one-way binding and Bind
is for two way binding. Using Eval
allows you to get the content into your page, but ASP.Net will not be able to put it back into an object for you.
Eval
方法只是 DataBinder.Eval
的简写.此外,Container.DataItem("Property")
实际上与 Eval
方法相同,除非您想返回路径"的值.例如,您可以使用点分隔的路径"调用 Eval
到您想要其值的公共属性,但我不相信您可以使用 Container.DataItem("属性")
.
The Eval
method is just shorthand for DataBinder.Eval
. Also, Container.DataItem("Property")
is effectively the same as the Eval
method except for when you want to return the value of a "path". For instance you can call Eval
with a dot-separated "path" to a public property that you want the value of, but I do not believe you can do this with Container.DataItem("Property")
.
这篇关于Databinder.Eval 和 Container.DataItem 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!