Performance of DataBinder.Eval

D

DBLWizard

Howdy All,

I was reading an older posting about the performance hit of
DataBinder.Eval.

http://groups-beta.google.com/group....Eval(Container&rnum=4&hl=en#a02b1685ae0f63c0

Am I correct in understanding that

<%# ((DataRowView)Container.DataIt­em)["EmployeeName"] %>

would have better performance than
<%# DataBinder.Eval(Container.DataIt­em, ["EmployeeName"]) %>

Does anybody have comments on this or is there a better way to set the
values of the Template Column?

thanks

dbl
 
K

Karl Seguin

DBL:
You are correct.

I can't give you numbers, but you ARE correct.

I will say 1 more thing however. Casting DataItem to the specific item
might be faster, but it violates your tiers and makes it harder to maintain.
Your presentation shouldn't know what TYPE of data source is being bound, it
should be implementation independent. The minute you start casting
everything, you make it a realy pain in the ass to change if you start using
collections or datasets.

Sometimes the penalty is too high to pay, but in my opinion in this case,
I'd strongly suggest you use DataBinder.Eval unless you have compelling
reasons why you shoudln't in your particular case.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


Howdy All,

I was reading an older posting about the performance hit of
DataBinder.Eval.

http://groups-beta.google.com/group....Eval(Container&rnum=4&hl=en#a02b1685ae0f63c0

Am I correct in understanding that

<%# ((DataRowView)Container.DataIt­em)["EmployeeName"] %>

would have better performance than
<%# DataBinder.Eval(Container.DataIt­em, ["EmployeeName"]) %>

Does anybody have comments on this or is there a better way to set the
values of the Template Column?

thanks

dbl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top