asp.netsql-serverdatabound

Joined tables and databound controls; how would I bind my image controls so they will be bound to different images?


I didn't know exactly how to phrase this question, so sorry if it sounded a little weird to you guys. It is a follow up to my question about joined tables and table aliases, only this time my issue is with the ASP.NET markup.

As I said in my previous question, I am making a cheat page for the game Doodle Creatures. I have a Select statement that joins two image directories - Animals and Genes - in order to display the images as shown below. The script now works, but one of my image bindings is wrong.

Here are the first five combinations as they should be:

My image bindings are wrong. I laughed a little bit when I realized it.  :-) I am so close!! :-D

Here are the combos as they are now:

Any suggestions?


Solution

  • I think your issue has everything to do with SELECT * - your query has the Animals table specified twice, and the select is returning every field of every table, so you might be getting something like...

    I'm not sure how Bind("AnimalImage") ends up selecting which instance of the AnimalImage field, but my bet is on the SELECT * being the culprit.

    Instead of SELECT *, specify exactly which fields you need to fetch, and make sure each field name only appears once in your result set:

    SELECT 
         Animal1.AnimalImage AS AnimalImage1
        ,Animal2.AnimalImage AS AnimalImage2
    ...
    

    Then you can Bind("AnimalImage1") when you want the image from the Animal1 table, and to AnimalImage2 when you want the image from the Animal2 table.