문제

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