Solved

asp.net 2010 vb formview

Posted on 2012-03-26
2
232 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now