What is the standard ASP.net data binding syntax?

Microsoft's introduction to data binding using a controlasp:Repeater gives the syntax a choice of value:

<b><%# DataBinder.Eval(Container.DataItem, "orderid") %></b>

This syntax is repeated in other introductions to ASP.net Repeatercontrol :

<a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>">...</a>

But I remember this syntax as "bad" and "wrong." From the MSDN documentation, DataBinder.EvalI see:

enter image description here Note

Because this method performs late-valued evaluations using reflection at run time, this can result in significant performance degradation compared to the strong syntax of the standard ASP.NET data binding syntax.

(accents added)

So this explains why I had a memory of " Evalis bad". But what " ASP.NET"?

+5
3

, , " ":

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

, x%. ? (-) .

+3

, " ASP.NET" , , GridView, .

, foreach DataReader HTML stringBuilder StringBuilder Literal.

+1

This MSDN page describes the standard data binding syntax as follows:

In the following code snippet, for example, an integer is displayed as a string of currency. With the standard ASP.NET data binding syntax, you must first specify the data row type in order to get the IntegerValue data field. This is then passed as an argument to the String.Format method:

<%# String.Format("{0:c}", ((DataRowView)Container.DataItem)["IntegerValue"]) %> 
0
source

All Articles