title: C#.net Input string was not in correct format
body: <p>I have written a function called on change of a value in a dropdown box.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>protected void ddlDistrict_SelectedIndexChanged(object sender, EventArgs e)
  {
      try
      {
          IApplicationContext ctx = ContextRegistry.GetContext();
          IServices reg = (IServices)ctx.GetObject("Services");
  
          if (ddlDistrict.SelectedIndex != 0)
          {
              Int32 DistrictID = Convert.ToInt32(ddlDistrict.SelectedValue);
  
              ddlTaluka.DataSource = reg.getTalukaList(DistrictID));
              ddlTaluka.DataTextField = "TalukaName";
              ddlTaluka.DataValueField = "TalukaID";
              ddlTaluka.DataBind();
              ddlTaluka.Items.Clear();
              ddlTaluka.Items.Insert(0, new ListItem("-- Select Taluka --", "0"));
          }
          else
          {
              ddlTaluka.Items.Clear();
              ddlTaluka.Items.Insert(0,new ListItem("-- Select Taluka --", "0"));
          }
      }
      catch (Exception ex)
      {
  
  
      }
  }
  </code></pre>
  
  <p>On change of a value in district dropdown taluka dropdown should be refilled...but 
  I am getting error</p>
  
  <blockquote>
    <p>Input string was not in correct format</p>
  </blockquote>
  
  <p>in this line</p>
  
  <pre><code>Int32 DistrictID = Convert.ToInt32(ddlDistrict.SelectedValue);
  </code></pre>
  
  <p>I am not understanding how to resolve this error.</p>