I have a page where I don't need a visual grid, but just want to programmatically create a RadGrid so I can use its export to ExcelML function. I am getting "RadGrid must be databound before exporting." I am calling DataBind(), so I really must be missing something simple here. Any suggestions?
protected void btnExport_Click(object sender, ImageClickEventArgs e) |
{ |
DataTable dtExport = ExecTools.General.GetResCodeTreeExport(Application["ExecData"].ToString()); |
Telerik.Web.UI.RadGrid ExportGrid = new RadGrid(); |
ExportGrid.AutoGenerateColumns = true; |
ExportGrid.DataSource = dtExport; |
ExportGrid.DataBind(); |
ExportGrid.ExportSettings.Excel.FileExtension = "xls"; |
ExportGrid.ExportSettings.FileName = "ResCodes"; |
ExportGrid.ExportSettings.ExportOnlyData = true; |
ExportGrid.ExportSettings.IgnorePaging = false; |
ExportGrid.ExportSettings.OpenInNewWindow = true; |
ExportGrid.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML; |
ExportGrid.MasterTableView.ExportToExcel(); |
} |