Redisplay data in DetailsView if error encountered during insert

Discussion in 'ASP .Net' started by Jim Coyne, Nov 28, 2006.

  1. Jim Coyne

    Jim Coyne Guest

    Is there a way to have the data controls re-populated with the previous data
    if an error was encountered during an insert?

    I currently have the following code to display the error message, but would
    like to re-populate the data:

    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
    If (Not e.Exception Is Nothing) Then
    lblStatus.Text = "ERROR: Data not saved."
    lblErrorMessage.Text = e.Exception.Message
    e.ExceptionHandled = True
    Else
    Response.Redirect("Default.aspx")
    End If
    End Sub

    I know the user can press "Back" to get the data, but that is not very
    user-friendly.

    Thanks

    Jim
     
    Jim Coyne, Nov 28, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AB@
    Replies:
    2
    Views:
    1,370
  2. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    416
    Dmitry Korolyov
    Sep 22, 2003
  3. Feege
    Replies:
    0
    Views:
    468
    Feege
    Dec 20, 2005
  4. JPElectron

    redisplay a page without any of the hyperlinks

    JPElectron, May 2, 2004, in forum: ASP General
    Replies:
    4
    Views:
    148
    JPElectron
    May 2, 2004
  5. Pratik kapadia
    Replies:
    1
    Views:
    243
    Curt_C [MVP]
    Sep 9, 2005
Loading...

Share This Page