I was looking for the easiest way to take a datagrid full of data including
two template columns, and export the contents of the grid into Excel by
giving an "open or save as" box.
I came across the following control which I thought might do it:
http://www.codeproject.com/aspnet/Ex...ort_button.asp
However, I'm not sure if I added the control correctly to my project via
VS2003 or if I am handling the Datagrid to what appears to be required as a
DataView for the Control.
Webform works fine without the control button added.
The error I'm currently getting is:
Unable to generate code for a value of type 'System.Data.DataView'. This
error occurred while trying to generate the property value for Dataview.
Code is as follows:
....
<pnwc:exportbutton id="ExportButton1" runat="server"
FileNameToExport="rptAttachmentFiles.xls" ExportType="Excel"
DataView="DataView1"></pnwc:exportbutton>
....
Protected WithEvents ExportButton1 As PNayak.Web.UI.WebControls.ExportButton
....
My first thought was to try:
Dim DataTable1 As DataTable
Dim DataView1 As DataView
DataTable1 = CType(DataGrid1.DataSource, DataTable)
DataView1 = DataTable1.DefaultView
to convert the Datagrid to a DataView. Is that correct?
Also, doesn't matter if I rem out these DataTable and DataView lines. Same
error.
Thank you in advance.
Rob