Databinder.Eval 和 Container.DataItem 有什么区别? [英] What's the difference between Databinder.Eval and Container.DataItem?

查看:26
本文介绍了Databinder.Eval 和 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆