I am using a radgrid populated by a standard object datasource with a matching data entity. The grid populates fine and everything is operating fine except for when the Add New Record button is clicked the grid loses its current page and goes to the last page of the grid.
I found a nifty way to stop that from happening along with preventing an edit and insert from occuring at the same time see code 1. This code block is firing on ItemCommand Insert Command.
The problem is when I call e.Canceled it completely messes up my ItemDataBound function that is populating a drop down list used to pick a value on insert. How can I do both, keep the drop down list populating appropriately and keep my paging where it started when the AddNewRecord was clicked? I am open to a solution that doesn't use code block 1 as i think it may over complicate it but I need some help on how to tackle the problem. Any ideas?
Code 1
I found a nifty way to stop that from happening along with preventing an edit and insert from occuring at the same time see code 1. This code block is firing on ItemCommand Insert Command.
The problem is when I call e.Canceled it completely messes up my ItemDataBound function that is populating a drop down list used to pick a value on insert. How can I do both, keep the drop down list populating appropriately and keep my paging where it started when the AddNewRecord was clicked? I am open to a solution that doesn't use code block 1 as i think it may over complicate it but I need some help on how to tackle the problem. Any ideas?
Code 1
switch (e.CommandName.ToUpper()) {
case "INITINSERT":
grid.MasterTableView.ClearEditItems();
//Ensure the grid doesn't jump to the last page
e.Canceled = true;
int pageIndex = e.Item.OwnerTableView.CurrentPageIndex;
e.Item.OwnerTableView.InsertItem();
e.Item.OwnerTableView.CurrentPageIndex = pageIndex;
e.Item.OwnerTableView.Rebind();
return;
case "EDIT":
e.Item.OwnerTableView.IsItemInserted = false;
return;