关于combobox的数据绑定问题(输入字符串格式不正确),但是不知道原因,请高手帮忙
在窗体初始化的时候的正确代码
int iGrpNum=int.Parse(this.lBox_Group.SelectedValue.ToString());//这个parse是正确的
string getDanciCurntGrp="select danci from "+this.selectTable+" where groupNum="+iGrpNum;
SqlDataAdapter sqlCurntDanci=new SqlDataAdapter(getDanciCurntGrp,this.sqlConnection1);
sqlCurntDanci.Fill(dataSet1,"tbGrpDanci");
this.lBox_danci.DataSource=dataSet1;
this.lBox_danci.DisplayMember="tbGrpDanci.danci";
this.lBox_danci.ValueMember="tbGrpDanci.danci";
在响应事件的时候的代码,这一段代码,老是提示说输入字符串格式不正确,但这段代码是拷的初始化的代码呀
string strGrpNum=this.lBox_Group.SelectedValue.ToString().Trim();
int intGrpNum;
intGrpNum=int.Parse(strGrpNum);//出错行
单步跟踪了一下,发现strGrpNum在后段代码的值是:"System.Data.DataViewManagerListItemTypeDescriptor"
库中数据是整型