I am struggling with the Grid Export functionality.
To investigate, I took the export demo on my machine, checked that it worked fine.
Removed all excel formatting, checked that it worked fine.
Then, I removed the declarative section of the Grid DataSource and replaced that by a PopulateGrid() function in both the Page_Load and Button4_Click
At this stage, the demo still works BUT the file exported is empty.
Is there a reason why populating the grid "on the fly" would not work with the export to excel functionality?
Many Thanks
Eric
To investigate, I took the export demo on my machine, checked that it worked fine.
Removed all excel formatting, checked that it worked fine.
Then, I removed the declarative section of the Grid DataSource and replaced that by a PopulateGrid() function in both the Page_Load and Button4_Click
| <telerik:RadGrid ID="RadGrid1" AllowSorting="True" |
| AllowPaging="True" PageSize="10" runat="server" GridLines="None" |
| Width="95%" > |
| <MasterTableView Width="100%"></MasterTableView> |
| </telerik:RadGrid> |
| protected void Button4_Click(object sender, System.EventArgs e) |
| { |
| PopulateGrid(); |
| ConfigureExport(); |
| RadGrid1.ExportSettings.Excel.Format = Web.UI.GridExcelExportFormat.ExcelML; |
| CheckBox1.Checked = true; |
| RadGrid1.ExportSettings.ExportOnlyData = true; |
| RadGrid1.MasterTableView.ExportToExcel(); |
| } |
| void PopulateGrid() |
| { |
| SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString); |
| SqlCommand cmd = new SqlCommand("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers", conn); |
| conn.Open(); |
| SqlDataReader reader = cmd.ExecuteReader(); |
| RadGrid1.DataSource = reader; |
| RadGrid1.DataBind(); |
| } |
Is there a reason why populating the grid "on the fly" would not work with the export to excel functionality?
Many Thanks
Eric