Syntax for field outside code-behind

Posted on 2005-04-11
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

    "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 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

    in your sql query
    select as id1, as id2, c.idas id3 ......

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now