I have a DetailsView control like so:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="IssueId"
DataSourceID="edsIssues" DefaultMode="Insert" OnItemInserted="DetailsView1_ItemInserted"
OnItemInserting="DetailsView1_ItemInserting" OnItemUpdated="DetailsView1_ItemUpdated"
OnItemUpdating="DetailsView1_ItemUpdating">
<Fields>
After inserting and updating I want to redirect to another page (a list page containing a GridView). So I did this:
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
Response.Redirect("IssueList.aspx");
}
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
Response.Redirect("IssueList.aspx");
}
When inserting a new record it works fine. However, when updating a record the Redirect causes the Update to cancel.
If I remove the Repsonse.Redirect from ItemUpdated then the update works – but then the DetailsView loads blank (I guess in insert mode).
How can I redirect to another page after updating without cancelling the update?
Thanks in advance.
Although I don’t like the answer as it seems wrong – using Threading.Thread.Sleep() did in fact do the job. I would love to know if there was a better answer though.