Reputation: 101
I Have a page(manage-darkhast-maghale.aspx) that include a gridview and sqldatasourse.one of the gridview columns is a hyperlink that on click redirects users to (pasokhmaghale.aspx?darkhastMaghaleId={0}) in second page there is a formview and sqldatasourse. after double click on update button on edit template on code behind I have typed below codes to redirect user to first page.
protected void UpdateButton_Click(object sender, EventArgs e)
{
Response.Redirect("manage-darkhast-maghale.aspx");
}
but, after running site and clicking on update button only the page begin redirect and the data has no change on gridview and database. anyone can help me please?
Upvotes: 1
Views: 363
Reputation: 5596
Without seeing the code it is very hard to say. From the information you have provided I would say that you need to leave the CommandName
attribute on your Update
button in the EditItemTemplate
i.e.
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
I would add the following event to your FormView
that will execute when the record has been updated:
<asp:FormView ID="FormView1" runat="server" OnItemUpdated="FormView1_ItemUpdated"...
In your code behind for the FormView you should have the following:
protected void FormView1_ItemUpdated(object sender, System.Web.UI.WebControls.FormViewUpdatedEventArgs e)
{
if (e.Exception == null && e.AffectedRows > 0)
{
Response.Redirect("manage-darkhast-maghale.aspx");
}
}
Upvotes: 1