after every next click drop down list data is getting doubled itself

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pranav thakur
    New Member
    • Jan 2011
    • 1

    after every next click drop down list data is getting doubled itself

    I am writting a c# code in asp.net for dropdown lists.
    as follows:

    public void function1()
    {

    SqlCommand cmd;
    DataSet ds = new DataSet();
    SqlDataAdapter ad = new SqlDataAdapter( );

    cmd = new SqlCommand("Sel ect distinct client_name from client_list", cn);

    ad.SelectComman d = cmd;
    ad.Fill(ds, "client_lis t");
    DropDownList1.D ataSource = ds;
    DropDownList1.D ataTextField = "client_nam e";
    DropDownList1.D ataBind();
    }
    public void function2()
    {
    SqlCommand cmd;
    DataSet ds = new DataSet();
    SqlDataAdapter ad = new SqlDataAdapter( );

    cmd = new SqlCommand("Sel ect distinct site_location from client_list where client_name ='" + DropDownList1.S electedItem.ToS tring() + "'", cn);

    ad.SelectComman d = cmd;
    ad.Fill(ds, "client_lis t");
    DropDownList2.D ataSource = ds;
    DropDownList2.D ataTextField = "site_location" ;
    DropDownList2.D ataBind();
    }


    after every next click drop down list data is getting doubled itself.
    So can you plz help me to avoid this?

    Thanks.
Working...