I want to stop a formview from inserting if a record exists in the database (sql 2005). If you look at my code below, how can I make the FV terminate if the record exists? I can get the "Label2" to display if the record does exits, but can't stop the FV from inserting.
protected void FormView1Duplicate(object sender, EventArgs e)
{
TextBox aTextBox = (TextBox)FormView1.FindControl("VarietalTypeTextBox");
bool isExist = checkDulEmail(aTextBox.Text);
if (isExist)
{
Label2.Text = "This varietal already exists in the database";
//How do I stop the FV from Inserting
}
else
{
//Insert sql here
}
}