skaleem1
asked on
e.NewEditIndex value in the GridView1_RowEditing event are reset incorrectly for every page when AllowPaging is set to true
I am programatically adding columns to a gridview from a dataset and binding the gridview utilizing the related datatable. I am also adding the edit and delete buttons programatically as in the code below:
CommandField Edit = new CommandField();
Edit.HeaderText = "";
Edit.ShowEditButton = true;
Edit.EditText = "Edit";
Edit.UpdateText = "Save";
Edit.CancelText = "Cancel";
Edit.ItemStyle.ForeColor = System.Drawing.Color.FromN ame("#344F 3E");
this.GridView1.Columns.Add (Edit);
CommandField Delete = new CommandField();
Delete.HeaderText = "";
Delete.ShowDeleteButton = true;
Delete.ItemStyle.ForeColor = System.Drawing.Color.FromN ame("#344F 3E");
this.GridView1.Columns.Add (Delete);
When the Edit button is clicked, the GridView1_RowEditing event fires where I am redirecting to another page passing few querystring parameters including the row index info as e.NewEditIndex (the logic for editing is done in the redirected page utilizing this row info passed). See the following code:
public void GridView1_RowEditing(objec t sender, GridViewEditEventArgs e)
{
Response.Redirect(string.F ormat("~/L ookupAddEd itData.asp x?mode={0} &op={1}&ro w={2}&sour ce={3}", _pageMode, "edit", e.NewEditIndex, "Released"));
}
Every thing worked fine when the Gridview1.AllowPaging was set to false. However, when I changed this to true, the e.NewEditIndex counter is reset for every page thus giving me the erroneous row info (for each page it starts with the lowest value again and again). How can I resolve this problem, any ideas, code and thoughts will be very much appreciated.
Thanks
CommandField Edit = new CommandField();
Edit.HeaderText = "";
Edit.ShowEditButton = true;
Edit.EditText = "Edit";
Edit.UpdateText = "Save";
Edit.CancelText = "Cancel";
Edit.ItemStyle.ForeColor = System.Drawing.Color.FromN
this.GridView1.Columns.Add
CommandField Delete = new CommandField();
Delete.HeaderText = "";
Delete.ShowDeleteButton = true;
Delete.ItemStyle.ForeColor
this.GridView1.Columns.Add
When the Edit button is clicked, the GridView1_RowEditing event fires where I am redirecting to another page passing few querystring parameters including the row index info as e.NewEditIndex (the logic for editing is done in the redirected page utilizing this row info passed). See the following code:
public void GridView1_RowEditing(objec
{
Response.Redirect(string.F
}
Every thing worked fine when the Gridview1.AllowPaging was set to false. However, when I changed this to true, the e.NewEditIndex counter is reset for every page thus giving me the erroneous row info (for each page it starts with the lowest value again and again). How can I resolve this problem, any ideas, code and thoughts will be very much appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.