Container.DataItem Question

S

Sparky Arbuckle

My SQL statement is as follows:

Dim strSQL = "SELECT tblDescription.ASIN, tblDescription.strTitle,
tblDescription.strArtist, tblDescription.strReview,
tblDescription.strImageDir, tblStyleASIN.StyleID, tblStyleASIN.ASIN " &
_
"FROM tblStyles INNER JOIN (tblDescription INNER JOIN
tblStyleASIN ON tblDescription.ASIN = tblStyleASIN.ASIN) ON
tblStyles.StyleID = tblStyleASIN.StyleID " & _
"WHERE tblStyles.StyleID = " & strID & ";"

This is bound to a DataList in the body of my ASP.NET page. The problem
is I run into an error when I input the following into my datalist:

<a href="ProductPage.aspx?ASIN=<%# DataBinder.Eval(Container.DataItem,
"ASIN") %>">Read More</a></FONT>

The error I get is:

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the
name ASIN

Could it be that I have a couple of different possible ASIN fields such
as tblDescription.ASIN, tblStyleASIN.ASIN, etc. . .? I want
Container.DataItem, "ASIN) to equal tblDescription.ASIN. Is there a way
to go about doing this?

Thanks in advance!
 
E

Elton Wang

How about

Dim strSQL = "SELECT tblDescription.ASIN,
tblDescription.strTitle,
tblDescription.strArtist, tblDescription.strReview,
tblDescription.strImageDir, tblStyleASIN.StyleID,
tblStyleASIN.ASIN AS ASIN_Style FROM ..."

HTH,

Elton Wang
 
S

Sparky Arbuckle

That way wouldn't work because there are 3 different tables that I am
relationing.
 
E

Eliyahu Goldin

Did it try it? What Elton means, you can rename result set columns as you
wish with AS keyword.

You should be able also to use
DataBinder.Eval(Container.DataItem,"tblDescription.ASIN")

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top