Thursday, March 29, 2012

Performance of DataBinder.Eval

Howdy All,

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

http://groups-beta.google.com/group...02b1685ae0f63c0

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

dblDBL:
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!)

"DBLWizard" <ibflyfishin@.yahoo.com> wrote in message
news:1121106912.352713.81740@.g44g2000cwa.googlegro ups.com...
Howdy All,

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

http://groups-beta.google.com/group...02b1685ae0f63c0

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

0 comments:

Post a Comment