asp.net - 什么是标准的 ASP.net 数据绑定(bind)语法?

标签 asp.net data-binding databinder

微软介绍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 文档我明白:

enter image description here 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)语法”?

奖金阅读
  • Data-Binding Expression Syntax
  • 最佳答案

    我认为你可以做一个 Actor 来避免“后期绑定(bind)”的惩罚:

    <%# (((System.Data.DataRowView)Container.DataItem)["URL"]) %>
    

    现在假设您将性能提高了 x%。对您的应用程序是否值得?权衡(在我看来)是可读性较差。

    关于asp.net - 什么是标准的 ASP.net 数据绑定(bind)语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10588449/

    相关文章:

    javascript - ajax 调用成功后更改 @Html.DisplayFor 项目

    asp.net - 通过 asp.net 网页进行 Web 服务器监控

    asp.net - 使用 CN 名称匹配域名在 IIS 7 上创建自签名证书

    data-binding - 我可以使用工厂函数来绑定(bind) "sap.ui.table.Table"控件中的行和列吗?

    c# - 为什么单击按钮后我的更新按钮文本不显示?

    wpf - "{Binding Path=.}"在 WPF 绑定(bind)中意味着什么?

    java - 将空值绑定(bind)到 Play Framework 2 (Java) 中的数字字段

    asp.net - 在 asp.net 控件的样式属性中使用 DataBinder.Eval()

    json - Scala 发送 GET 请求,无法解析 json 响应

    c# - 追踪黑客/恶意软件企图