private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(this.comboBox1.SelectedValue);     这里报错:无法将类型为“System.Data.DataRowView”的对象强制转换为类型“System.IConvertible”。
            DataSet ds = personalManager.getPeopleByBranchId(id);
            this.comboBox4.DataSource = ds.Tables["Personnal"];
            this.comboBox4.DisplayMember = "PersonnalName";
            this.comboBox4.ValueMember = "PersonnalId";
        }
应该是在这个事件里写的吧

解决方案 »

  1.   

    看一下他的comboBox1.SelectedValue是int类型的吗?监视一下
      

  2.   

    事件没错应该是  是comboBox1的绑定错了你先获取下 this.comboBox1.SelectedValue的值  要是不能转换为int型的话 
     
    就是comboBox1的绑定错了
      

  3.   

    我是这么绑的//将部门显示到下拉列表框中
                this.comboBox1.DataSource = personalManager.getBranch();
                this.comboBox1.DisplayMember = "BranchName";
                this.comboBox1.ValueMember = "BranchId";
    获取的时候 int num=Convert.ToInt32(this.comboBox1.SelectedValue),这样是可以的啊
      

  4.   

    跟一下,看看SelectedValue是什么·
      

  5.   

    DataRowView drv = (DataRowView)comboBox1.SelectedItem;
    string Id = drv.Row["id"].ToString();
      

  6.   

     
    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
      //int id = Convert.ToInt32(this.comboBox1.SelectedValue); 这里报错:无法将类型为“System.Data.DataRowView”的对象强制转换为类型“System.IConvertib……int id = int.Parse(this.comboBox1.SelectedValue.tostring());