Redisplay data in DetailsView if error encountered during insert

J

Jim Coyne

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,343
Messages
2,571,418
Members
48,794
Latest member
massivestack

Latest Threads

Top