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";
}
应该是在这个事件里写的吧
{
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";
}
应该是在这个事件里写的吧
就是comboBox1的绑定错了
this.comboBox1.DataSource = personalManager.getBranch();
this.comboBox1.DisplayMember = "BranchName";
this.comboBox1.ValueMember = "BranchId";
获取的时候 int num=Convert.ToInt32(this.comboBox1.SelectedValue),这样是可以的啊
string Id = drv.Row["id"].ToString();
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());