简体   繁体   English

输入字符串格式不正确

[英]Input String is not a correct format

Have been trying this for days now, i want to view my recorded data for an update purpose by double clicking on the informations from data grid view, meanwhile i get "Input String was not in a correct format" error. 现在已经尝试了几天,我想通过双击数据网格视图中的信息来查看记录的数据以进行更新,同时出现“输入字符串格式不正确”错误。 My code: 我的代码:

private void dgvGroundtech_Double Click(object sender, EventArgs e){

if(dgvGroundtech.CurrentRow.Index != -1)
{
Id = Convert.ToInt32(dgvGroundtech.CurrentRow.Cells[0].ToString());
txtName.Text = dgvGroundtech.CurrentRow.Cells[1].ToStrings();
   txtItem.Text = dgvGroundtech.CurrentRow.Cells[2].ToStrings();
   txtMobileNumber.Text = dgvGroundtech.CurrentRow.Cells[3].ToStrings();
   cmbPurpose.Text = dgvGroundtech.CurrentRow.Cells[4].ToStrings();
   txtAddress.Text = dgvGroundtech.CurrentRow.Cells[5].ToStrings();
   txtAmount.Text = dgvGroundtech.CurrentRow.Cells[6].ToStrings();
   txtDate.Text = dgvGroundtech.CurrentRow.Cells[7].ToStrings();
}
}

This line will potentially throw a format exception. 该行可能会引发格式异常。

Id = Convert.ToInt32(dgvGroundtech.CurrentRow.Cells[0].ToString());

Check the values for this 检查此值

dgvGroundtech.CurrentRow.Cells[0].ToString()

do not fall into this category:: 不属于此类别::

"value does not consist of an optional sign followed by a sequence of digits (0 through 9)." “值不包含一个可选的符号,后跟一个数字序列(0到9)。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM