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

When cancel on new, record is still created

Using 2008 SQL Server Management Studio and am using Microsoft Visual Web Developer 2008 Express Edition

New MasterID created via "New" button & on subsequent pages the user is to select the components to be added by passing MasterID to individual pages that are automatically assigned PageID when request for "new" component(PAGE) .  This takes them to a details view page where they are to answer many question & submit(or rather update) for those answer to be written to database.

Problem is if I request a "new" record to be created, the new pageID is created & passed to detailsview.   Say I then want to "cancel" rather than update.  What code do I include in my "cancel" button to delete this new record?

Code from Detailview page where "New" button lives...
    Protected Sub btnNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Me.SqlDataSource1.InsertParameters("MasterId").DefaultValue = Session("RFQMasterId")
       Dim iReturn As Int32 = Me.SqlDataSource1.Insert()
        Response.Redirect("CorrDisch.aspx")
        Dim sValue As String = Me.GridView1.Rows(Me.GridView1.Rows.Count - 1).Cells(1).Text
        Session("corrId") = sValue
        Response.Redirect("CorrDischDetail.aspx")
    End Sub
Code for Detailsview cancel/update:
Protected Sub DetailsView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles DetailsView1.ItemCommand
        If e.CommandName = "Cancel" Then
            Response.Redirect("CorrDisch.aspx")
        ElseIf e.CommandName = "Update" Then
        Else
            MsgBox("ItemCommand " + e.CommandName)
        End If
    End Sub

Protected Sub SqlDataSource1_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Updated
        Response.Redirect("CorrDisch.aspx")
    End Sub
0
acs6699
Asked:
acs6699
  • 2
  • 2
1 Solution
 
VishnukumarCommented:
Please use SavePoint and Rollback functionality to rollback your transactions.
0
 
acs6699Author Commented:
I am trying to do that.  Will let you know how it turns out.  Thanks
0
 
VishnukumarCommented:
0
 
acs6699Author Commented:
thanks a million
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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