My code is executing the OnItemInserting function but not the OnItemInserted. Have I declared the Inserted function correctly?
aspx
<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert" OnItemInserting="Insert" OnItemInserted="Inserted">
vb
Protected Sub Insert(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting
' Works
End Sub
Protected Sub Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted
Response.Redirect("Login.aspx") ' Never gets here
End Sub
The code never enters the Inserted function and just refreshes the form after executing the Insert
ItemInsertedevent will be raised only if FormView is data-bound and the data-source handles the insert (and subsequently call backs the control after insert).I suspect that you have not bound your form-view to any data source control (such as SqlDataSource). In case, you are planning to handle inserting into the data-store by writing custom code then you should do that part in
ItemInsertingevent itself.