Skip to content
Loading
  • Sachin Singh
    +1
    hey
    please test with making datasource null as well
    1. private void countrycomboBox_SelectedIndexChanged(object sender, EventArgs e)    //here I am stuck state not load based on country      
    2.  {      
    3.      countrycomboBox.DataSource=null;  
    4.       countrycomboBox.Items.Clear();    
    5.      statecomboBox.DataSource=null;  
    6.      statecomboBox.Items.Clear();    
    7.      ComboBox cmb = (ComboBox)sender;      
    8.           
    9.     int selectedValue = (int)cmb.SelectedValue;      
    10.      BindStateByCountry(selectedValue);    
    11.         
    12.  }     
    1. private void Form1_Load_1(object sender, EventArgs e)   //load country successfully in combobox        
    2.  {     
    3. countrycomboBox.DataSource=null;    
    4.     countrycomboBox.Items.Clear();         
    5.      BindCountry();     
    6.      statecomboBox.DataSource=null;  
    7.           statecomboBox.Items.Clear();      
    8.  } 

    +1
  • +1
    error is not come but issue is not solved
     
    1. private void countrycomboBox_SelectedIndexChanged(object sender, EventArgs e)  
    2.         {  
    3.             statecomboBox.DataSource = null;  
    4.             statecomboBox.Items.Clear();  
    5.             ComboBox cmb = (ComboBox)sender;  
    6.   
    7.             string selectedValue = (string)cmb.SelectedValue;  
    8.             BindStateByCountry(selectedValue);  
    9.         }  
    10. private void Form1_Load_1(object sender, EventArgs e)  
    11.         {  
    12.             
    13.             countrycomboBox.DataSource = null;  
    14.             countrycomboBox.Items.Clear();  
    15.             statecomboBox.DataSource = null;  
    16.             statecomboBox.Items.Clear();  
    17.             BindCountry();  
    18.         }  
     
    +1
  • Sachin Singh
    +1
    when items are cleared then there is no chance of duplicate , i can't guess what is happening in your case.
    +1