I have a web app (ASP.NET 2.0 C#), and on one of the pages I have a Gridview
. The Gridview
has 3 columns (Edit, ID, Name), and sorting is enabled. The Edit doesn't work in the conventional way: It uses the ID and adds it to the QueryString
, and the user is taken to the Edit page. Something like this:
protected void Grid_RowEditing(object sender, GridViewEditEventArgs e)
{
string editID = Grid.DataKeys[e.NewEditIndex].Value.ToString();
Response.Redirect("~/Admin/Edit_Page.aspx?EditID=" +
HttpUtility.HtmlDecode(editID));
}
When the page loads, the grid is not sorted in anyway. If I click edit, it works fine. But if I click Edit AFTER sorting, it passes the ID of the row that was originally there, before sorting, instead of the one that is there at present.
Why is this happening? Any ideas?
Thank you.