• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

asp.net 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?

formview1.itemInserting.......
label1.text = "Item already exists"
end sub

I just can seem to find the right event.
0
bergertime
Asked:
bergertime
1 Solution
 
nishant joshiTechnology Development ConsultantCommented:
you can use on text change event of textbox,
0
 
gery128Commented:
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:

http://www.issociate.de/board/post/476944/Formview_and_Sql_Error_Trapping_and_Page_Validation....html
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now