Input string was not in a correct format in c#

  • Thread starter Thread starter Liliana Castro
  • Start date Start date
L

Liliana Castro

Guest
I created three combobox Country, Province and City when I choose one country automatically shows me Province and next I choose province will show me the city. I did this process before with the Student Screen but right now I am working with Teacher Screen and it does not working it is showing the error Input string was not in a correct format in c# when I try to choose the Country in the combobox.

========================================================================

private void cmb_province_teach_SelectedIndexChanged_1(object sender, EventArgs e)
{
try
{
int pro = Convert.ToInt32(cmb_province_teach.SelectedValue.ToString());
adpt = new SqlDataAdapter("select * from city where province_id='" + pro + "'", con.opencon());
dt = new DataTable();
adpt.Fill(dt);
cmb_city_teach.DataSource = dt;
cmb_city_teach.DisplayMember = "CityName";
cmb_city_teach.ValueMember = "city_id";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

}
}


===========================================================================

Continue reading...
 
Back
Top