Вопрос

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top