|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Repeater HelpMy 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 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! -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Jamie Sutherland" <ja***@sutherlandwest.plus.comnospam> wrote in message news:uRvKWeMAGHA.2708@TK2MSFTNGP12.phx.gbl... > 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 >
Error Rendering Control - ButtonSearch An unhandled exception has occurred. There was an error pars
Result not expected with user control - any ideas why/ Label Style Problem adding attributes to DataListItem.. OnDayRender won't render Customizing create user wizard ObjectDataSource DateTime isuue with en-gb culture CSS Issue With User Control in an HTML Table Templated User Control & intellisense Steven Cheng, could you please take a look at the exception? |
|||||||||||||||||||||||