未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中。其他信息: 输入字符串的格式不正确。问题代码
public DataRow drUpdate;drUpdate = dataSet11.Tables["student"].Rows.Find(Int32.Parse(txtSNo.Text)); 当跑到drUpdate时就会出问题
public DataRow drUpdate;drUpdate = dataSet11.Tables["student"].Rows.Find(Int32.Parse(txtSNo.Text)); 当跑到drUpdate时就会出问题
验证txtSNo.Text 只能输入数字
验证txtSNo.Text 只能输入数字
加一个检查错误的
或者txtSNo.Text是否包含特殊字符。比如空格之类的
只有整形类型的字符串才可以用Int32.Parse转换为整数
int key = Int32.Parse(txtSNo.Text);
drUpdate = dataSet11.Tables["student"].Rows.Find(key);