I just started learning asp.net webforms and came across the problem. I am looking at Repeater control and came across this. What is the difference between the three lines of code?
<%#Container.DataItem("title", "name")%>
<%#DataBinder.Eval(Container.DataItem, "title", "name")%>
<%#Eval("title", "name")%>
Do the three produce the same output? If so, what is the difference and which should I use? Thanks,
Container.DataItem(string, string)
is a single row of the datasource, its of the tipe of your LINQ query final Select
. DataBinder.Eval
allows you to access a public property of the DataItem object. It's powerful but uses reflection at runtime so it can be really slow. Eval
is a shorthand for DataBinder.Eval
References
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.