Question : Formview insert doesnt insert data if I add postbackurl on button

Hello,

I have a form with an insert button as follows:
--------
<asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Submit"> </asp:Button>
-------

however, when i use the "postbackurl" option, the data is not inserted into the database. I would like to have a "thank you" page acknowledging the user's time.

How and where can i add a "Response.Redirect("ThankYou.aspx");
 so that the data is inserted and the user gets routed to the "thank you' page?


Answer : Formview insert doesnt insert data if I add postbackurl on button

You simply use SqlDataSource OnInserted event to redirect like :

protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        if (e.Exception == null)
        {
            Response.Redirect("tothankyoupage");
        }
    }
Or even ItemInsereted event of FV.
Random Solutions  
 
programming4us programming4us