Search and display three dropdownlists with search button
<p>I've created a search function with 3 DropDownLists and a search button. How will I display it on the same page?</p>

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

<pre><code>public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //read sql server connection string from web.config file
            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)
    {
        string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
        SqlConnection conn = new SqlConnection(constring);
        DataTable dt = new DataTable("emed_province");

        using (conn)
        {
            conn.Open();
            PROVINCE_CODE = '" + ddlProvince.SelectedValue + "'", conn);
            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)
    {
        string constring = ConfigurationManager.ConnectionStrings["AccreString"].ConnectionString;
        SqlConnection conn = new SqlConnection(constring);
        DataTable dt = new DataTable("emed_city");

        using (conn)
        {
            conn.Open();
        PROVINCE_CODE = '" + ddlProvince.SelectedValue + "'", conn);
            SqlCommand comm = new SqlCommand("SELECT * FROM emed_doctors_hospitals     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);
        }
        ddlSched.DataSource = dt;
        ddlSched.DataTextField = "SCHEDULE";
        ddlSched.DataValueField = "HOSPITAL_CODE";
        ddlSched.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}
</code></pre>

<p>When someone selects a value in the DropDownList and hits the button, it will display the lists of doctors available in the province, city and per particular schedule. </p>
