What's the difference between
<%# DataBinder.Eval (Container.Data Item,"LastName" ) %>
&
<%# Container.DataI tem("LastName") %>
Thanks 6 15843
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
Active property, I want to pass to a function like so:
<%#fx(CBool(container.dataitem("Active")))%>...
|
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='<%#
string.Format("~/Products.aspx?page=0&categoryId={0}",
|
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" ID="HyperLink1" NavigateUrl='<%#
string.Format("~/Products.aspx?page=0&categoryId={0}",
|
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") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |