I found a workaround for anyone interested:
1- wire the ItemCommand, ItemInserted and ItemUpdated events in your grid:
OnItemCommand="RadGrid1_ItemCommand" OnItemInserted="RadGrid1_ItemInserted" OnItemUpdated="RadGrid1_ItemUpdated"
2- Handle the events to prevent excel exporting while the grid does not contain data:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (Session["cancelExcelExport"] == null)
{
Session["cancelExcelExport"] = false;
}
if (e.CommandName == RadGrid.EditCommandName || e.CommandName == RadGrid.InitInsertCommandName)
{
Session["cancelExcelExport"] = true;
}
if (e.CommandName == RadGrid.CancelCommandName)
{
Session["cancelExcelExport"] = false;
}
if (e.CommandName == RadGrid.ExportToExcelCommandName && (bool)Session["cancelExcelExport"] == true)
{
e.Canceled = true;
}
}
protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
{
Session["cancelExcelExport"] = false;
}
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
Session["cancelExcelExport"] = false;
}
Hope this helps someone.