简体   繁体   中英

What's the difference between the following code when using DataBinder?

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,

  1. Container.DataItem(string, string) is a single row of the datasource, its of the tipe of your LINQ query final Select .
  2. 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.
  3. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM