Hi There,
I have been scouring the web for an asnwer on something I would have thought was quite common. Any help would be greatly appreciated.
I have a database which contain job ads/
I have one table "dbo.tbl_jobadvert" which contains the ad itself and another table "dbo.tbl_jobFiles" which contains the path of the document(s) uploaded in relations to the job advert ( application form, job description, etc )
dbo.tbl_jobadvert has this structure:
id, jobTitle,Salary,Organisation .....and a few other fields
dbo.tbl_jobFiles has this structure:
filepath, filename, id, VacancyRef (which is a foreign key from the dbo.tbl_jobadvert (id)) .....and a few other fields
I would like to query those tables and get the result in a datalist or datagrid which would display like that.
-----------------------------------------------------
Job Title: Job1
Salary: £25000
Job description: http://..whatever the path in the db is for this doc
Appliction form: http://..whatever the path in the db is for this doc
Job Profile: http://..whatever the path in the db is for this doc
==============================================================
My Problem is that currently I return this:
Job Title: Job1
Salary: £25000
Job description: http://..whatever the path in the db is for this doc
Job Title: Job1
Salary: £25000
Appliction form: http://..whatever the path in the db is for this doc
Job Title: Job1
Salary: £25000
Job Profile: http://..whatever the path in the db is for this doc
==============================================================
Here is my C# code behind:
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["recruitmentHubConnectionString"].ConnectionString;
// Initialise Connection
conn = new SqlConnection(connectionString);
comm = new SqlCommand("SELECT DISTINCT jobTitle,filePath,fileName,jobBand_Salary FROM dbo.tbl_JobAdvert, dbo.tbl_jobFiles WHERE dbo.tbl_jobFiles.VacancyRef = dbo.tbl_JobAdvert.id", conn);
// Open the connection
conn.Open();
myDataReader = comm.ExecuteReader();
//HERE ???
jobDetailsDL.DataSource = myDataReader;
jobDetailsDL.DataBind();
}
and the front end:
<asp:DataList ID="jobDetailsDL" runat="server">
<ItemTemplate>
<strong>Job Title:</strong>
<asp:Label ID="jobTitleLabel" runat="server" Text='<%# Eval("jobTitle") %>'></asp:Label><br />
<strong>Salary:</strong>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("jobBand_Salary") %>'></asp:Label><br />
<asp:HyperLink ID="HyperLink2" NavigateUrl='<%# Eval("filePath")%>' Text='<%# Eval("fileName") %>' runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
Thanks a lot
Chris