title: Failed to convert parameter value from a String to a Int32 error
body: <p>My issue is that while submitting the data into the database I am getting error as </p>
  
  <blockquote>
    <p><em>Failed to convert parameter value from a String to a Int32.</em></p>
  </blockquote>
  
  <p>Here is my code:-</p>
  
  <pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
  {
          SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString);
          foreach (GridViewRow row in ImagesGrid.Rows)
          {
              var title = row.FindControl("txtTitle") as TextBox;
              var description = row.FindControl("txtDescription") as TextBox;
              var imageFile = row.FindControl("flUpload") as FileUpload;
  
              using (SqlCommand cmd = conn.CreateCommand())
              {
                  conn.Open();
                  SqlCommand cmd1 = new SqlCommand("Insert into tbl_galleries_stack (gallery_id,img_title,img_desc,img_path,IsDefault) values (@gallery_id,@img_title,@img_desc,@img_path,@IsDefault)", conn);
                  cmd1.Parameters.Add("@gallery_id", SqlDbType.Int).Value = ddlgallery.SelectedItem.Text;
                  cmd1.Parameters.Add("@img_title", SqlDbType.VarChar).Value = title;
                  cmd1.Parameters.Add("@img_desc", SqlDbType.VarChar).Value = description;
                  cmd1.Parameters.Add("@img_path", SqlDbType.NVarChar).Value = imageFile;
                  cmd1.Parameters.Add("@IsDefault", SqlDbType.Bit).Value = Convert.ToInt32(chkDefault.Checked);
                  cmd1.ExecuteNonQuery();
                  conn.Close();
                  ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Teachers profile added sucessfully');window.location ='csrgalleriesstack.aspx';", true);
              }
  
          }
  }
  </code></pre>
  
  <p>I tried changing to <code>Int32</code> for the checkbox but it is not working.</p>