I en bok som jag har står det att DataBinder.Eval är resurskrävande och att man inte ska använda den om det inte verkligen behövs.
Dum fråga: Vad ska man använda istället (i en DataList t.ex.)?
<%# DataBinder.Eval(Container.DataItem, "colName") %>
4 svar · 448 visningar · startad av Web-Tor
I en bok som jag har står det att DataBinder.Eval är resurskrävande och att man inte ska använda den om det inte verkligen behövs.
Dum fråga: Vad ska man använda istället (i en DataList t.ex.)?
<%# DataBinder.Eval(Container.DataItem, "colName") %>
Det funkar inte riktigt:
Compiler Error Message: CS1502:
The best overloaded method match for 'System.Convert.ToString
(object, System.IFormatProvider)' has some invalid arguments
Kan citera boken som jag fått detta ifrån.
<%# Container.dataitem("colName") %>This syntax explicity casts the data item to a datarowview object and then accesses the "colName" item. Because this item is a string value, there is no need to cast it as well. If it were another type of object we could use the ToString method in order to be able to output it to the screen.
<%# DataBinder.Eval(Container.DataItem, "colName") %>This method uses reflection to allow for using late-bound objects in the databinding declarative output. While this method is easier to write, it comes with preformance penalty. Because the information is late bound and reflection is used, this method will cost you and should only be used in RAD enviroments where preformance is not a major concern.
Lite läsning hittar du längst ned på den här sidan:
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatabinding.aspx