Fetching and displaying tables on database
<p>I'm just starting out at asp.net c# and I have been given a task to generate the available doctors upon the given values in a drop-down list.</p>

<p>I have 3 drop-down lists, (1)PROVINCE, (2)CITY, (3)SPECIALIZATION and a search button.
After the user selects the values of 3 drop-down lists and hits the search button it will print a table containing the available doctor.</p>

<p>I know that the key is on the search button, but I don't exactly know what to put under  the search button. Can you help me out please?</p>

<p>Here's my code:</p>

<pre><code>       protected void Page_Load(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(2000);

        if (!IsPostBack)
        {
            string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
            SqlConnection conn = new SqlConnection(constring);
            DataTable dt = new DataTable("emed_province");

            using (conn)
            {
                conn.Open();
                SqlCommand comm = new SqlCommand("SELECT *  FROM emed_province ORDER BY PROVINCE_NAME ASC", conn);
                SqlDataAdapter adptr = new SqlDataAdapter(comm);
                adptr.Fill(dt);
            }

            ddlProvince.DataSource = dt;
            ddlProvince.DataTextField = "PROVINCE_NAME";
            ddlProvince.DataValueField = "PROVINCE_CODE";
            ddlProvince.DataBind();
        }
    }

    protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(2000);

        string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
        SqlConnection conn = new SqlConnection(constring);
        DataTable dt = new DataTable("emed_province");

        using (conn)
        {
            conn.Open();
            SqlCommand comm = new SqlCommand("SELECT * FROM emed_city WHERE PROVINCE_CODE =@pcode", conn);
            comm.Parameters.AddWithValue("@pcode", ddlProvince.SelectedValue);
            SqlDataAdapter adptr = new SqlDataAdapter(comm);
            adptr.Fill(dt);

            SqlParameter param = new SqlParameter();
            param.ParameterName = "@pcode";
            param.Value = ddlProvince;

            comm.Parameters.Add(param);
        }
        ddlCity.DataSource = dt;
        ddlCity.DataTextField = "CITY_NAME";
        ddlCity.DataValueField = "CITY_CODE";
        ddlCity.DataBind();
    }

    protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(2000);

        string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
        SqlConnection conn = new SqlConnection(constring);
        DataTable dt = new DataTable("emed_city");

        using (conn)
        {
            conn.Open();
            SqlCommand comm = new SqlCommand("select distinct emed_accredited_providers.SPECIALIZATION from emed_accredited_providers inner join emed_doctors_hospitals on emed_accredited_providers.DOCTOR_CODE = emed_doctors_hospitals.DOCTOR_CODE where CITY_CODE =@ccode", conn);
            comm.Parameters.AddWithValue("@ccode", ddlCity.SelectedValue);
            SqlDataAdapter adptr = new SqlDataAdapter(comm);
            adptr.Fill(dt);

            SqlParameter param = new SqlParameter();
            param.ParameterName = "@ccode";
            param.Value = ddlCity;

            comm.Parameters.Add(param);
        }
        ddlSpec.DataSource = dt;
        ddlSpec.DataTextField = "SPECIALIZATION";
        ddlSpec.DataValueField = "SPECIALIZATION";
        ddlSpec.DataBind();
    }

    protected void btnDocs_Click(object sender, EventArgs e)
    {

    }
}
}
</code></pre>
