while (dr.Read())
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add(Convert.ToString(dr["RegionName"]))
}
On Jul 23, 4:20 pm, IT MILAN PITAM PURA <[email protected]> wrote:
> Hi,
> i am gyanesh. i just want to discuss a problem with you. the scenario
> is as follows:
> i am having two drop down list controls in my web page. the first drop
> down is accessing regionid from a table and second drop down list is
> accessing the regionname from the database and show it into the second
> drop down list. now whenever i am selecting a value it adds the value
> in the second drp down list. but i want when i am accessing an id from
> the first drop down list it will reset the second and drop down list
> and show the value automatically. for that i am providing u the code
> which is written by me.
>
> ---------------------------
> protected void DropDownList1_SelectedIndexChanged(object sender,
> EventArgs e)
> {
> if (IsPostBack)
> {
> SqlConnection con = new SqlConnection
> ("server=del-00222-srvmr;database=adventureworks;user
> id=sa;password=.");
> string info = DropDownList1.Text;
> con.Open();
> SqlCommand cmd = new SqlCommand("Select * from cinema
> where region...@id", con);
> cmd.Parameters.Add(new SqlParameter("@id", info));
> SqlDataReader dr = cmd.ExecuteReader();
> while (dr.Read())
> {
> DropDownList2.get
> }
> con.Close();
> }
>
> }