473,803 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Binding Expression Syntax

JV

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work identically
in both languages?

Can anyone explain the arcane rules of this syntax?

Nov 17 '05 #1
11 4835
You should typecast Container. In the case of datagrid it will look like

<%# (DataRowView)Co ntainer.DataIte m("columnName ") %>

DataBinder.Eval uses reflection at runtime and, therefore, is much slower.

Eliyahu

"JV" <jo**********@g oisc.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work identically
in both languages?

Can anyone explain the arcane rules of this syntax?

Nov 17 '05 #2
Maybe try:
<%# Container.DataI tem["columnName "] %>

"JV" <jo**********@g oisc.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work identically
in both languages?

Can anyone explain the arcane rules of this syntax?

Nov 17 '05 #3
JV
Tried that first, got another error.

"Sharon" <sh****@void.nu ll> wrote
Maybe try:
<%# Container.DataI tem["columnName "] %>

"JV" <jo**********@g oisc.com> wrote

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work
identically
in both languages?

Can anyone explain the arcane rules of this syntax?

Nov 17 '05 #4
JV
Ah, yes, I didn't look into performance. I did see that I could typecast,
but I haven't seen that done anywhere and it looked a bit clunky, so I went
the other route. Also, this article
(http://msdn.microsoft.com/library/de...sionsyntax.asp)
seems to push the Eval method.

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote
You should typecast Container. In the case of datagrid it will look like

<%# (DataRowView)Co ntainer.DataIte m("columnName ") %>

DataBinder.Eval uses reflection at runtime and, therefore, is much slower.

Eliyahu

"JV" <jo**********@g oisc.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work
identically
in both languages?

Can anyone explain the arcane rules of this syntax?


Nov 17 '05 #5
C# is morte typesafe than VB as does not support late binding (except thru
the .net reflection api). the expression inside <%# %> must be a valid C$
expression amd return a string. for most binding objects, an object is
returned. aslo if you use an indexer, you must switch from () to []. the
DataBinder.Eval was written for C# to help with handling this and some late
binding issues.

-- bruce (sqlwork.com)


"JV" <jo**********@g oisc.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work identically
in both languages?

Can anyone explain the arcane rules of this syntax?

Nov 17 '05 #6
Bruce,

In all Net languages is a procedure stated with (). In VBNet is that as well
for a index from a collection or an array where that is in the C languages
[].

Most VBNet programmers have Option Strict On in there IDE by what is dynamic
binding of an object prevented in the code. (Late binding by reflection is
in all languages allowed).

For all the dotNet languages is the code for the Databinder Eval exact equal
when it is done in the ASPX part.

http://msdn.microsoft.com/library/de...evaltopic1.asp

Cor
Nov 17 '05 #7
JV
And actually that generates an error as well:

Compiler Error Message: CS0246: The type or namespace name 'DataRowView'
could not be found (are you missing a using directive or an assembly
reference?)

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
You should typecast Container. In the case of datagrid it will look like

<%# (DataRowView)Co ntainer.DataIte m("columnName ") %>

DataBinder.Eval uses reflection at runtime and, therefore, is much slower.

Eliyahu

"JV" <jo**********@g oisc.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..

I just converted a big web project from VB.NET to C# and I got some very
strange runtime errors. Apparently, throughout the ASPX pages, the VB
version of this project used the expression <%#
Container.DataI tem("columnName ") %> inside an <ItemTemplate > tag for
DataGrid. Apparently though this works fine in VB.NET, for some reason C#
chokes on it. I have found that replacing those expressions with <%#
DataBinder.Eval (Container.Data Item, "columnName ")%> makes the errors go
away, but I can't figure out why. It seems to me that the evaluation of
data binding expressions embedded in the ASPX page should work
identically
in both languages?

Can anyone explain the arcane rules of this syntax?


Nov 17 '05 #8
JV
Well, I think it's apparent that there is still a lot of confusion about
this, so it is not clearly enough documented.

What doesn't make sense to me is what the VB application works fine with
just <%# Container.DataI tem("someName") %> when the C# one does not. If
that is meant to be array syntax, then one would think that <%#
Container.DataI tem["someName"] %> would work, but it does not.

"Cor Ligthert" <no************ @planet.nl> wrote
Bruce,

In all Net languages is a procedure stated with (). In VBNet is that as
well for a index from a collection or an array where that is in the C
languages [].

Most VBNet programmers have Option Strict On in there IDE by what is
dynamic binding of an object prevented in the code. (Late binding by
reflection is in all languages allowed).

For all the dotNet languages is the code for the Databinder Eval exact
equal when it is done in the ASPX part.

http://msdn.microsoft.com/library/de...evaltopic1.asp

Cor

Nov 17 '05 #9
JV,

Just Google and you get this page, in my opinion does it says everthing that
you ask for.

http://weblogs.asp.net/rajbk/archive...20/188868.aspx

I am fighting as well forever with the documentation from the eval on MSDN.
When I would have to tell what are the ten worst documented parts on MSDN.
Then I would surely have the Eval in it..

Cor
Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2094
by: gaudetteje | last post by:
I just read in the 'What's New in Python 2.4' document that the None data type was converted to a constant: http://python.org/doc/2.4/whatsnew/node15.html """ # None is now a constant; code that binds a new value to the name "None" is now a syntax error. """ So, what's the implications of this? I find the lack of explanation a
4
5408
by: | last post by:
I have a datagrid with a template column that has a hyperlink and a label. The hyperlink text is bound to Title from my dataset and the label text is bound to Author in the dataset. The grid displays with the template columns showing the Title and the Author from the first row in all rows. The other none template columns are fine. Obviously I am not understanding something here. What am I missing????? -- Barry Fitzgerald
5
1778
by: Brian Henry | last post by:
Hello, I am working on a simple email website that is kinda like hotmail... but the listing of messages is in a data grid data bound to a table called messages... now one of the columns in the messages data table is called read if the value is 1 the message is read if 0 then unread... what i want to do is show an image in the listing based on that value, if 1 then icn-msg-read.gif will be showed in that column for that message row, if 0...
0
5679
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet) at TryThis.Form1.save() in C:\Documents and Settings\Nick\My Documents\...
11
1744
by: JV | last post by:
I just converted a big web project from VB.NET to C# and I got some very strange runtime errors. Apparently, throughout the ASPX pages, the VB version of this project used the expression <%# Container.DataItem("columnName") %> inside an <ItemTemplate> tag for DataGrid. Apparently though this works fine in VB.NET, for some reason C# chokes on it. I have found that replacing those expressions with <%# DataBinder.Eval(Container.DataItem,...
4
3236
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
3
1769
by: Wilson | last post by:
Hi, Can I do data binding for a textbox in a webform at server side ? not using the Data Binding Expression. Thanks Wilson
18
2063
by: mdh | last post by:
>From p112 ( K&R). Given an array declared as static char arr= { { 0,1,........},{0,1,.....}}; let arr be passed as an argument to f. f( int (*arr) ) {....} It is noted that the parentheses are necessary else it would be
6
4608
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
Oralloy
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...
0
10310
jinu1996
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...
0
10068
tracyyun
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...
0
9121
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4275
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
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.