webForumDet fria alternativet

DataBinder.Eval

4 svar · 448 visningar · startad av Web-Tor

Web-TorMedlem sedan nov. 200011 794 inlägg
#1

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") %>
DinoMedlem sedan sep. 20011 918 inlägg
#2

Jag använder.

<%# Container.dataitem("colName") %>
Web-TorMedlem sedan nov. 200011 794 inlägg
#3

Det funkar inte riktigt:

Compiler Error Message: CS1502:
The best overloaded method match for 'System.Convert.ToString
(object, System.IFormatProvider)' has some invalid arguments
DinoMedlem sedan sep. 20011 918 inlägg
#4

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.

NETworkMedlem sedan juni 20011 679 inlägg
#5

Lite läsning hittar du längst ned på den här sidan:

http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatabinding.aspx

Genererad på 379 ms · cache AV · v20260730165559-full.f96bc7eb