DataSet and Looping through rows

Hi,

I am having a problem with this code, i had a post on this however this code is slightly different to that so i thought i would post a spearate thread.

Anyway, what i am trying to do is display job vacancies by the result of a DropDownList value. Now each job name has a description. The problem i am having is i need to display the results in this logic:

  1. Job name
  2. Job description
  3. Job location

But what is happening is the job description (body) is repeating the more vacancies there are. This is the page:

http://kidsunlimited.co.uk/vacancies_test_two.aspx

If you select Deputy Nursery Manager from the DropDown and hit the Search button you will see the results. After listing the first two locations the description is repeated and then the 3rd location is shown after this. This is my code:


protected void Button1_Click(object sender, EventArgs e)
    {
        string connVac = "...";
        SqlConnection dbConnVac = new SqlConnection(connVac);

        DataSet dsInfo = new DataSet();

        string sqlVac = "SELECT DISTINCT tbl_vacancies.job_name, tbl_job_titles.body, tbl_vacancies.job_id, " +
                         "tbl_vacancies.location, tbl_vacancies.voucher FROM tbl_vacancies INNER JOIN tbl_job_titles ON " +
                         "tbl_vacancies.job_name = tbl_job_titles.name WHERE (tbl_vacancies.availability = 'Live') " +
                         "AND tbl_vacancies.job_name = '" + DropDownList1.SelectedValue + "'";

        dbConnVac.Open();

        SqlCommand dbVac = new SqlCommand(sqlVac, dbConnVac);
        SqlDataAdapter adapter = new SqlDataAdapter();

        adapter = new SqlDataAdapter();
        adapter.SelectCommand = dbVac;
        adapter.Fill(dsInfo, "JobDetails");

        dbConnVac.Close();

        int icount = 0;

        bool display = false;
        string jobname = "";

        if (dsInfo.Tables[0].Rows.Count > 0)
        {
            Label1.Visible = true;
            Label2.Visible = true;

            Label1.Text = "Latest on the site";

            for (icount = 0; icount < dsInfo.Tables["JobDetails"].Rows.Count; icount++)
            {
                jobname = dsInfo.Tables["JobDetails"].Rows[icount]["job_name"].ToString().ToLower();
                if (icount == 0 || jobname != dsInfo.Tables["JobDetails"].Rows[icount - 1]["job_name"].ToString().ToLower())
                {
                    Label2.Text += "<div id='vacancies'><p><strong>" + dsInfo.Tables["JobDetails"].Rows[icount]["job_name"].ToString() + "</strong></p>";
                    display = false;
                }

                if (jobname == dsInfo.Tables["JobDetails"].Rows[icount]["job_name"].ToString().ToLower())
                {
                    if (display == false)
                    {
                        Label2.Text += "<p>" + dsInfo.Tables["JobDetails"].Rows[icount]["body"].ToString() + "</p>";
                        display = true;
                    }
                    else
                    {
                        display = false;
                    }
                }
                Label2.Text += "<div style='padding:10px; border:1px solid #333; width:400px; margin-bottom:4px'><p><span style='color:#990000'>" + dsInfo.Tables["JobDetails"].Rows[icount]["location"].ToString() + "</span> - <em>" + dsInfo.Tables["JobDetails"].Rows[icount]["voucher"].ToString() + "</em></p></div>";
                if (icount == (dsInfo.Tables["JobDetails"].Rows.Count - 1) || jobname != dsInfo.Tables["JobDetails"].Rows[icount + 1]["job_name"].ToString().ToLower())
                {
                    Label2.Text += "</div>";
                }
            }
        }
        else
        {
            Label1.Visible = true;
            Label1.Text = "Sorry, no vacancies for this job.";
        }
    }

Can anyone please help?

Kind regards,