I have radgrid with
void Grid_DeleteCommand(object source, GridCommandEventArgs e)
GridDataItem dataItem = (GridDataItem)e.Item;
string name= dataItem["Name"].Text;
var Id= (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
InsertGridMessage("Name: " + name+ " is deleted!", false);
catch (Exception ex)
"Name: " + name+ " cannot be deleted. Reason: " + ex.Message, true);
void InsertGridMessage(string message, bool isFailure)
var lblMessage = new Label
Text = message,
ForeColor = isFailure?
}When i delete the item for first time it all works fine. But any action on radgrid will throw following exception. The reason is because the viewstate is not updated. Any ideas?
I get following error
Webpage error details
Message: Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.