- Home
- Forum
- ASP.NET Web Forms
- Grid export to excel no record to display
Grid export to excel no record to display
Thanks for contacting Syncfusion support.
In the provided code, you are using Grid dataSource directly to Export() method, which is the cause for the issue.
While setting data source to Grid using sqlDataSource element, the Grid dataSouce will be Null. So it will show the “No records to display” message. Give the list of data to export method and convert SQL data as list data, and use that data in Export() method.
Please refer to the following code example, sample,
|
protected void FlatGrid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e) { ExcelExport exp = new ExcelExport(); DataView data = (DataView)SqlData.Select(new DataSourceSelectArguments()); IList data1 = data; DataTable dt = data.Table; var emp = (from DataRow row in dt.Rows
select new Order { OrderID = Convert.ToInt32(row["OrderID"]), CustomerID = row["CustomerID"].ToString(), Freight = Convert.ToDouble(row["Freight"]), EmployeeID = Convert.ToInt32(row["EmployeeID"]), ShipCountry = row["ShipCountry"].ToString()
}).ToList(); exp.Export(FlatGrid.Model, (IEnumerable)emp, "Export.xlsx", ExcelVersion.Excel2010, true, true, "flat-lime"); |
Sample: http://www.syncfusion.com/downloads/support/forum/120716/ze/Sample_120716-599975427
Regards,
Sellappandi R
Hi Rapops,
We are happy that the provided suggestion helped you.
Please get back to us if you need any further assistance.
Regards,
Sellappandi R
Hi Rapops,
We are happy that the provided suggestion helped you.
Please get back to us if you need any further assistance.
Regards,
Sellappandi R
- 4 Replies
- 2 Participants
-
RA rapops
- Oct 7, 2015 05:59 PM UTC
- Oct 12, 2015 04:30 AM UTC