Syntax for field outside code-behind

Posted on 2005-04-11
Medium Priority
Last Modified: 2010-04-07
I have an interesting question. I have a SQL JOIN with 3 databases with the same field in common, ID.  In the SQL statement, they are referenced as a.ID, b.ID and  c.ID.

 If I call the generic field ID I get an error when I reference it like:  
<%# DataBinder.Eval(Container.DataItem, "ID") %>

Is there a way that I can reference this field??
Question by:Kittrick
LVL 33

Accepted Solution

raterus earned 1600 total points
ID: 13756499
"id" is a sql server reserved word, you are probably running into problems because of this.  The best way to fix this is to alias it

Select a.id as MyID, b.field1, c.field2
from atable
<%# DataBinder.Eval(Container.DataItem, "MyID") %>

If you still get an error, you can know it's not because of reserved words!
LVL 12

Assisted Solution

laotzi2000 earned 400 total points
ID: 13756502
in your sql query
select a.id as id1, b.id as id2, c.idas id3 ......

Then you can use id1, id2 and id3 to get the field

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question