微软介绍data-binding using the asp:Repeater
control 给出了获取值的语法:
<b><%# DataBinder.Eval(Container.DataItem, "orderid") %></b>
此语法在 other introductions to the ASP.net
Repeater
control 上重复。 :<a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>">...</a>
但我记得这种语法是“坏的”和“错误的”。来自
DataBinder.Eval
的 MSDN 文档我明白:Note
Because this method performs late-bound evaluation, using reflection at run time, it can cause performance to noticeably slow compared to standard ASP.NET data-binding syntax.
(重点补充)
这就解释了为什么我有“
Eval
不好”的内存。但是什么是 “标准 ASP.NET 数据绑定(bind)语法”?奖金阅读
最佳答案
我认为你可以做一个 Actor 来避免“后期绑定(bind)”的惩罚:
<%# (((System.Data.DataRowView)Container.DataItem)["URL"]) %>
现在假设您将性能提高了 x%。对您的应用程序是否值得?权衡(在我看来)是可读性较差。
关于asp.net - 什么是标准的 ASP.net 数据绑定(bind)语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10588449/