What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
Thanks 6 15827
On Sep 24, 8:51 am, r...@rediffmail .com wrote:
What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
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.DataI tem 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.
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.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Sep 24, 8:51 am, r...@rediffmail .com wrote:
>What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
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.DataI tem 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.
On Sep 24, 2:13 am, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Sep 24, 8:51 am, r...@rediffmail .com wrote:
What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
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.DataI tem 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.
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....
On Sep 24, 10:24 am, r...@rediffmail .com wrote:
On Sep 24, 2:13 am, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Sep 24, 8:51 am, r...@rediffmail .com wrote:
What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
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.DataI tem 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.
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....- Hide quoted text -
- 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.
I agree. I've heard that same argument (about performance) from Nikhil
Kothari himself.
--
Teemu Keiski
AspInsider, ASP.NET MVP http://blogs.aspadvice.com/joteke http://teemukeiski.net
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:OU******** ******@TK2MSFTN GP05.phx.gbl...
>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.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
>On Sep 24, 8:51 am, r...@rediffmail .com wrote:
>>What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
Thanks
DataBinder.Eva l 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.Data Item 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.
On Sep 24, 5:25 pm, "Teemu Keiski" <jot...@aspalli ance.comwrote:
I agree. I've heard that same argument (about performance) from Nikhil
Kothari himself.
--
Teemu Keiski
AspInsider, ASP.NET MVPhttp://blogs.aspadvice .com/jotekehttp://teemukeiski.net
"Eliyahu Goldin" <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te in
messagenews:OU* *************@T K2MSFTNGP05.phx .gbl...
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.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Sep 24, 8:51 am, r...@rediffmail .com wrote: What's the difference between
><%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
>&
><%# Container.DataI tem("LastName") %>
>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.DataI tem 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.- Hide quoted text -
- Show quoted text -
My quote regarding performance was from here http://msdn2.microsoft.com/en-us/library/4hx47hfe.aspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: az bij |
last post by:
Hi,
I have a dataset bound to a repeater and want to place some logic in
my ascx file. I want to display an image link if and only if an image
is available.
I have tried without success variations of:
<%#if(DataBinder.Eval(Container.DataItem,"ImageFilename"!="")){%>
<a href="#"><img src=<%#DataBinder.Eval(Container.DataItem,
|
by: Mike P |
last post by:
I'm having trouble with C# syntax for Container.DataItem. This is the
VB version. CAn anybody help me out with the syntax?
<asp:DataList runat="server" id="dlResults"
Font-Name="Verdana" Font-Size="10pt">
<ItemTemplate>
<span style="font-size:15pt;font-weight:bold;">
<%# Container.DataItem.title %>
</span><br />
|
by: Lauchlan M |
last post by:
Hi
In my aspx page HTML I have
<a href='<%# DataBinder.Eval(Container.DataItem, "Name") %>'> <%#
DataBinder.Eval(Container.DataItem, "Name") %>
I am trying to create a hyperlink to
applicationroot\FileUploads\Filename.FileExtension.
|
by: anony |
last post by:
Hi,
I would like to find out if it's possible to check the value of a
Container.DataItem inside the Datagrid's <ItemTemplate> tag .... based on
it's value, I would to either output it or output another DataItem from the
current resultset. Something like this:
<ItemTemplate>
If container.dataitem( "column" ) <> "none" Then
|
by: bg |
last post by:
Hi!
How do I check if "date" exists before using that code?
I've built a RSSreader and sometimes there's a date in it and sometimes not.
How can I check if it exists to avoid crash (DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name date)
<asp:DataGrid
id="RssNewsGrid"
| |
by: hsomob1999 |
last post by:
I have a class, lets call it Schmuck. It has 2 public properties Name
(string) and active (boolean). When I bind to a Repeater, like so:
<%#container.dataitem("Name")%> i get the following error: No default
datamember found for type Schmuck. The Schmucks are in a ArrayList.
When I use DataBinder.Eval, i have no prob. But for say the boolean...
|
by: Antony |
last post by:
Hello,
in my aspx.file I have this code inside a datagrid:
<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='upload/<%# Container.DataItem("photo")%>'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
|
by: John Davis |
last post by:
Hi all, hope you are well.
I would like to know if I can access the strongly typed properties of my
datatable when binding through the ObjectDataSource object.
I am currently creating some hyperlinks in a repeater bound to an
objectdatasource with the following code:
<asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl='<%#...
|
by: John Davis |
last post by:
Hi all, hope you are well.(not sure if this posted the first time)
I would like to know if I can access the strongly typed properties of my
datatable when binding through the ObjectDataSource object.
I am currently creating some hyperlinks in a repeater bound to an
objectdatasource with the following code:
<asp:HyperLink runat="server"...
|
by: alberthung01 |
last post by:
Hi all,
I try to use Container.DataItem() in my DataGrid's ItemTemplate.
Somewhere it works fine.
eg.<input type=checkbox id='cb_select_<%# Container.DataItem("TAG_ID")
%>' value='<%# Container.DataItem("TAG_NAME") %>'>
but somewhere the server returns the expression was wrong.
<asp:ImageButton id="IB_Edit<%# Container.DataItem("TAG_ID")...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |