On Sep 24, 8:51 am, r...@rediffmail.com wrote:
> What's the difference between
>
[quoted text clipped - 5 lines]
>
> Thanks
DataBinder.Eval is a helper function to evaluate data, and it use
reflection (late binding) to find right property in your item. You can
display data without using DataBinder.Eval, but you need to cast
Container.DataItem to the right type.
Note: Because DataBinder.Eval performs late-bound evaluation, using
reflection at run time, it can cause performance to noticeably slow
compared to explicit casting.
Eliyahu Goldin - 24 Sep 2007 09:08 GMT
I used to advocate explicit casting in this newsgroup a while ago. There was
a strong opposition to it from quite experienced developers claiming that
the performance gain is not that significant comparing with the advantages
of using Eval. The major one is that with Eval you can change your
datasource without touching your databinding expressions. I can hear this
argument very well.

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
> On Sep 24, 8:51 am, r...@rediffmail.com wrote:
>> What's the difference between
[quoted text clipped - 15 lines]
> reflection at run time, it can cause performance to noticeably slow
> compared to explicit casting.
Teemu Keiski - 24 Sep 2007 16:25 GMT
I agree. I've heard that same argument (about performance) from Nikhil
Kothari himself.

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
>I used to advocate explicit casting in this newsgroup a while ago. There
>was a strong opposition to it from quite experienced developers claiming
[quoted text clipped - 22 lines]
>> reflection at run time, it can cause performance to noticeably slow
>> compared to explicit casting.
Alexey Smirnov - 24 Sep 2007 18:49 GMT
> I agree. I've heard that same argument (about performance) from Nikhil
> Kothari himself.
[quoted text clipped - 38 lines]
>
> - Show quoted text -
My quote regarding performance was from here
http://msdn2.microsoft.com/en-us/library/4hx47hfe.aspx
rn5a@rediffmail.com - 24 Sep 2007 09:24 GMT
> On Sep 24, 8:51 am, r...@rediffmail.com wrote:
>
[quoted text clipped - 16 lines]
> reflection at run time, it can cause performance to noticeably slow
> compared to explicit casting.
Alexey, could you please show some examples of what you have
explained? Sorry I couldn't exactly follow the difference.
Thanks to both of you....
Alexey Smirnov - 24 Sep 2007 12:22 GMT
On Sep 24, 10:24 am, r...@rediffmail.com wrote:
> > On Sep 24, 8:51 am, r...@rediffmail.com wrote:
>
[quoted text clipped - 23 lines]
>
> - Show quoted text -
Here's a good article about that difference
http://odetocode.com/Articles/278.aspx
DataItem returns a reference to an object, and to return a value in
the proper type you need to cast it (especially for C#). Maybe it
makes no sense when we are talking just about simple strings but it
can be useful when you have some casting, e.g. show an integer as a
currency, etc.
DataBinder.Eval allows to avoid using casts because it finds
dynamically a property and its type by the name at runtime.