Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am doing ExportWithOpenXML kendo grid. I downloaded code here http://www.telerik.com/support/code-library/export-grid-to-excel[^].

Here in code I find this.
C#
public FileResult ExportWithOpenXML([DataSourceRequest]DataSourceRequest request)
{
    //Get the data representing the current grid state - page, sort and filter
    var products = new List<Product>(db.Products.ToDataSourceResult(request).Data as IEnumerable<Product>);


But am using repository methods i tried like this
C#
AssetMaintenanceRepository cmprep = new
    AssetMaintenanceRepository(Session["Connectionstring"].ToString());

var products = new List<MaintenanceReportSummary>(
    cmprep.GetMaintenanceSummary(
        new Guid(Session["CurrentCompanyId"].ToString()),
        new Guid(Session["AssetId"].ToString()))
.ToDataSourceResult(request).Data as IEnumerable<MaintenanceReportSummary>);

var products = cmprep.GetMaintenanceSummary(
    new Guid(Session["CurrentCompanyId"].ToString()),
    new Guid(Session["AssetId"].ToString()))
.ToDataSourceResult(request);

But am stuck at this place.

I am getting error Object reference not set to an instance of an object.

Please help me.


[Edit member="Tadit"]
Corrected formatting issues.
Added pre tags.
[/Edit]
Posted
v2

1 solution

Refer the most popular answer by Sergey "Object Reference not set to Instance of an object", please see the code below.[^].

Saying that, I would suggest you to post this in Telerik forums, so that you will get better replies.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900