我想在插入之前检查我的表单,以防止在我的数据库中插入重复的ProductSerial。 那么如何用我的数据库检查txtProductSerial.text,如果它是重复的我预防插入。 这是我的代码
protected void fvwSoldForm_ItemInserting(object sender, FormViewInsertEventArgs e)
{
e.Values["DateX"] = DateTime.Now;
e.Values["IsDeleted"] = false;
e.Values["Confirmed"] = false;
var solded = db.SoldedByResellers.ToList();
solded = solded.Where(p => p.ProductSerial == NumericSerial.Text).ToList();
if (solded.Count > 0)
Alert("Please Change the serial code, This code Used before");
//Here WHAT EVER I DO THE INSERTING GOES ON. I WANT TO STOP INSERTING HERE
}