Hi Experts,
I have a gridview which gets populated. I'm trying to create a dataset from it so I can export the dataset to excel.
When the "XL" button is clicked it calls a function which calls the lines:
DataSet ds = ((DataSet)GridView1.DataSo
urce);
ExportDataSetToExcel(ds, "Book1.xls");
As I step through the code, I notice ds is null.
When I get to populate a datagrid in the ExportdataSetToExcel function, I get this error:
NullReferenceException was unhandled by user code:
Object reference not set to an instance of an object.
.. this occurs on:
DataGrid dg = new DataGrid();
dg.Datasource = ds.Tables[0]; <--- here
What's going wrong?
Thank you,
rss2
Start Free Trial