Solved

asp.net 2010 vb formview

Posted on 2012-03-26
2
236 Views
Last Modified: 2012-04-02
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
Comment
Question by:bergertime
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Expert Comment

by:nishant joshi
ID: 37767306
you can use on text change event of textbox,
0
 
LVL 9

Accepted Solution

by:
gery128 earned 500 total points
ID: 37769926
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question