MVC4中的ExportWithOpenXML kendo Grid获取错误未将对象引用设置为对象的实例 [英] ExportWithOpenXML kendo Grid in MVC4 getting error Object reference not set to an instance of an object

查看:98
本文介绍了MVC4中的ExportWithOpenXML kendo Grid获取错误未将对象引用设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做ExportWithOpenXML kendo网格。我在这里下载了代码 http://www.telerik.com/support/code-library/ export-grid-to-excel [ ^ ]。



在代码中我找到了这个。

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.

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

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);



但我被困在这个地方。



我我收到错误对象引用没有设置为对象的实例



请帮助我。

< br $> b $ b



更正格式问题。

已添加标记。

[/ Edit]

推荐答案

参考Sergey最受欢迎的答案对象引用未设置为对象的实例,请参阅下面的代码。 [ ^ ]。



这样说,我建议你发布在 Telerik 论坛,以便您获得更好的回复。
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.


这篇关于MVC4中的ExportWithOpenXML kendo Grid获取错误未将对象引用设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆