2

I have this update link in DetailsView.

<asp:CommandField ShowEditButton="true" ShowCancelButton="false" ValidationGroup="VAL_1" />

When i click this link, its updates the content on the page. but i want to updates the content on the page and redirect to another page (ex: abc.aspx) after click on this.

How could i do this ?

1 Answer 1

7

Use the ItemCommand event:

in code behind:

protected void detailsview1_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
{
    if (e.CommandName == "Update")
    {
        Response.Redirect("abc.aspx", false);
    }
}

In aspx:

<asp:DetailsView runat="server" 
     ID="detailsview1" 
     OnItemCommand="detailsview1_ItemCommand" ...
Sign up to request clarification or add additional context in comments.

4 Comments

i have added your code into partial class. but its not worked. should i call this method from some where ?
Sorry I forgot the protected word
i have added it just now :). now page redirect is working. but content is not updating on page. there are some text fields on page data filling from database. i have changed data and click Update. page redirect is succeed. but my changes didn't updated.
Try Response.Redirect("abc.aspx", false); and/or e.Handled = false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.