Redirect to another page after inserting record

saturation
saturation used Ask the Experts™
on
I'm new to .NET.  I have a DetailsView page for inserting records, but when it saves, it stays on that page.   How can I take them back to my GridView page?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Engineer
Commented:
You use the protected ItemInserted event of the DetailsView.

<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" 
        oniteminserted="DetailsView1_ItemInserted" Width="125px">
    </asp:DetailsView>


    protected void DetailsView1_ItemInserted(object sender, System.Web.UI.WebControls.DetailsViewInsertedEventArgs e)
    {
         Response.Redirct("somepage.aspx");
    }

Open in new window

Author

Commented:
I did the code below on my .aspx.vb page for that DetailsView, but it's not redirecting back to Default.aspx.   What could be the problem?   The .aspx page is tied to this code page.
    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
        Response.Redirect("Default.aspx")
    End Sub

Open in new window

Author

Commented:
I forgot to put the

oniteminserted="DetailsView1_ItemInserted" in the GridView

Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial