Differences between 2 tags

G

Guest

Hi,

What are the differences between

<%# Container.DataItem("CustomerID") %>
and
<%# Databinder.eval(Container.DataItem, "CustomerID") %>

I saw both of them used in a lot of sample codes.

TIA
 
S

Scott Allen

They would both achieve the same result, but -

The first expression will only work if the language setting of the
page is "VB".

The second expression with DataBinder.Eval will work in either a
language = "VB" or a language = "C#" page.
 
B

bruce barker

1) the first is a direct method call returning the default data type. the
<%#%> operator is expecting a string return value. in the case of c#, a
compile/runtime error will return if the method does not return a string.

2) the eval method uses reflection, to execute the method. it always returns
a string.

| Hi,
|
| What are the differences between
|
| <%# Container.DataItem("CustomerID") %>
| and
| <%# Databinder.eval(Container.DataItem, "CustomerID") %>
|
| I saw both of them used in a lot of sample codes.
|
| TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top