尝试设置未在此报告中定义的报告参数“studentSignDateParameter”

时间:2016-07-20 15:32:28

标签: c# asp.net-mvc parameters reportviewer

所以我有一个包含参数的报告。

    ReportParameter cvrParameter = new ReportParameter("cvrParameter", companyCVR);
    ReportParameter companyNameParameter = new ReportParameter("companyNameParameter", company.CompanyName);
    ReportParameter companyAddressParameter = new ReportParameter("companyAddressParameter", company.Address);
    ReportParameter companyCityParameter = new ReportParameter("companyCityParameter", company.City);
    ReportParameter studentCityParameter = new ReportParameter("studentCityParameter", student.City);
    ReportParameter studentNameParameter = new ReportParameter("studentNameParameter", student.FirstName+" "+student.LastName);
    ReportParameter studentAddressParameter = new ReportParameter("studentAddressParameter", student.Address);
    ReportParameter studentZipCodeParameter = new ReportParameter("studentZipCodeParameter", student.ZipCode);
    ReportParameter jobStartDateParameter = new ReportParameter("jobStartDateParameter", projectobj.StartDate);
    ReportParameter jobEndDateParameter = new ReportParameter("jobEndDateParameter", projectobj.EndDate);
    ReportParameter jobDescriptionParameter = new ReportParameter("jobDescriptionParameter", projectobj.Description);
    ReportParameter jobHoursPerWeekParameter = new ReportParameter("jobHoursPerWeekParameter", projectobj.HoursPerWeek.ToString());
    ReportParameter jobHourlyRateParameter = new ReportParameter("jobHourlyRateParameter", projectobj.HourlyRate.ToString());
    ReportParameter cprParameter = new ReportParameter("cprParameter", studentCPR);
    ReportParameter studentSignDateParameter = new ReportParameter("studentSignDateParameter", DateTime.Today.ToString("dd/MM/yyyy"));
    ReportParameter companySignDateParameter = new ReportParameter("companySignDateParameter", contractobj.CompanySigningDate);
    ReportParameter companyRepNameParameter = new ReportParameter("companyRepNameParameter", contractobj.RepFirstName +" "+contractobj.RepLastName);
    ReportParameter projectWorkFromParameter = new ReportParameter("projectWorkFromParameter", projectobj.WorkFrom);


    localReport.SetParameters(new ReportParameter[] { cprParameter });
    localReport.SetParameters(new ReportParameter[] { cvrParameter });
    localReport.SetParameters(new ReportParameter[] { companyNameParameter });
    localReport.SetParameters(new ReportParameter[] { companyAddressParameter });
    localReport.SetParameters(new ReportParameter[] { studentNameParameter });
    localReport.SetParameters(new ReportParameter[] { studentAddressParameter });
    localReport.SetParameters(new ReportParameter[] { studentZipCodeParameter });
    localReport.SetParameters(new ReportParameter[] { jobStartDateParameter });
    localReport.SetParameters(new ReportParameter[] { jobEndDateParameter });
    localReport.SetParameters(new ReportParameter[] { jobDescriptionParameter });
    localReport.SetParameters(new ReportParameter[] { jobHoursPerWeekParameter });
    localReport.SetParameters(new ReportParameter[] { jobHourlyRateParameter });
    localReport.SetParameters(new ReportParameter[] { studentSignDateParameter });
    localReport.SetParameters(new ReportParameter[] { companySignDateParameter });
    localReport.SetParameters(new ReportParameter[] { companyRepNameParameter });
    localReport.SetParameters(new ReportParameter[] { projectWorkFromParameter });
    localReport.SetParameters(new ReportParameter[] { companyCityParameter });
    localReport.SetParameters(new ReportParameter[] { studentCityParameter });

如上所示,从控制器设置参数。

list of parameters

我在报告数据中添加了所有参数,其他所有参数都有效,但不是'studentSignDateParameter'。

enter image description here

尝试从参数的属性中指定它是一个日期,但我得到相同的结果。 “companySignDateParameter”工作正常,它是一个日期字符串。

我也试过给参数一个随机值,一个字符串或其他什么,但这个错误仍然存​​在。我不认为它与代码有关,因为Visual Studio没有检测到任何错误。

有什么想法吗?该参数可能出现什么问题?我删除了它并重新制作但没有任何变化。

1 个答案:

答案 0 :(得分:0)

找到解决方案!我实际上有另一个问题,当我修复它时,它也修复了这个问题。我在这里发布了

Trying to update a database entry but a new one is added