Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Container.DataItem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rn5a@rediffmail.com - 24 Sep 2007 07:51 GMT
What's the difference between

<%# DataBinder.Eval(Container.DataItem,"LastName") %>

&

<%# Container.DataItem("LastName") %>

Thanks
Alexey Smirnov - 24 Sep 2007 08:13 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.