2010 vb formview

I have a formview that does an insert.  When user inserts a duplicate key, it errors out, how can I catch this?  Something like this?

label1.text = "Item already exists"
end sub

I just can seem to find the right event.
Who is Participating?
gery128Connect With a Mentor Commented:
you might want to try FormView_ItemInserted event in which you can check EventArgs for proper information if the item has inserted or not.
here is some sample code:

protected void MyFormView_ItemInserted(object sender, FormViewInsertedEventArgs e)
      if (e.Exception != null)
            // display exception
            lblException.Text = e.Exception.ToString();
            e.KeepInInsertMode = true;
            e.ExceptionHandled = true;

Open in new window

from below link:
nishant joshiTechnology Development ConsultantCommented:
you can use on text change event of textbox,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.