我遇到了一个问题,当用户从数据网格视图中选择 id 并单击“删除”按钮时,错误提示我们如下:“输入字符串的格式不正确”。
下面是代码,让你们更好地理解代码。
private void btnDel_Click(object sender, EventArgs e)
{
using (satsEntities Setupctx = new satsEntities())
{
int ID = Int32.Parse(lblID.Text);
var DeleteSL = (from delLS in Setupctx.locationstations
where delLS.locationstationID == ID
select delLS).Single();
Setupctx.DeleteObject(DeleteSL);
Setupctx.SaveChanges();
this.Delete_LS_Load(null, EventArgs.Empty);
MessageBox.Show("Selected Location Station Has Been Deleted.");
}
}