Syntax for field outside code-behind

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??
LVL 4
KittrickAsked:
Who is Participating?
 
raterusCommented:
"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!
0
 
laotzi2000Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.