Repeater Help

J

Jamie Sutherland

Hi,
My page has a repeater control on it which puls data from my sql db. the
query string I have has several fields of the same name but from different
tables(shown below). On my aspx page I have the following:
<asp:Repeater id="rprActiveOp" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container, "DataItem.title") & " " &
DataBinder.Eval(Container, "DataItem.firstname") & " " &
DataBinder.Eval(Container, "DataItem.lastname")%>
<br>
<%# databinder.Eval(Container, "DataItem.College_Name") %>
</ItemTemplate>
</repeater>

How do I use the other fields with the same name but from the different
tables?


Dim strsql As String = "SELECT tbl_user_opps.opp_id, tbl_user_opps.Status,
tbl_User_Details.Title, tbl_User_Details.Firstname,
tbl_User_Details.Lastname, " & _
"tbl_colleges.College_Name, tbl_colleges.Address1,
tbl_colleges.Address2, tbl_colleges.Town, tbl_colleges.County,
tbl_colleges.PostalCode, " & _
"tbl_colleges.Telephone, tbl_colleges.Website, tbl_colleges.Title,
tbl_colleges.Firstname, tbl_colleges.lastname, tbl_colleges.JobTitle, " & _
"tbl_opportunities.Opp_Name FROM tbl_colleges INNER JOIN
tbl_User_Details ON tbl_colleges.College_Id = tbl_User_Details.College_Id
INNER JOIN " & _
"tbl_opportunities INNER JOIN tbl_user_opps ON
tbl_opportunities.opp_id = tbl_user_opps.opp_id ON tbl_User_Details.Username
= tbl_user_opps.Username " & _
"WHERE (tbl_user_opps.opp_id ='15') AND (tbl_user_opps.Status =
'Approved')"
Dim cmd As New SqlCommand(strsql, conn)
Try
conn.Open()
rprActiveOp.DataSource = cmd.ExecuteReader
rprActiveOp.DataBind()
Catch ex As Exception
Throw New Exception(ex.Message)



Thanks
Jamie
 
C

Christopher Reed

Use field alias within your query. For example,

SELECT tbl_user_detail.lastname AS user_lastname, tbl_colleges.lastname AS
college_lastname, ....

Then use the alias as you would the column name in your Repeater.

Hope this helps!
 

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
474,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top