我想将 Session[CountryList"] 用于数据源报告图表。
我将图表添加到报告中,但是没有代码。
如何将 Session[CountryList"] 添加为数据源并将其显示在我的报告图表中?
模型:
public static IList<Country> GetCountries()
{
return new List<Country>(){
new Country("Russia", 50),
new Country("Canada", 231),
new Country("USA", 33),
new Country("China", 111),
new Country("Brazil", 14),
new Country("Australia", 140),
new Country("India", 434),
new Country("Turkey", 3),
new Country("England", 21),
new Country("Greece", 116)
};
}
}
public class Country
{
string name;
double area;
public string Name { get { return name; } }
public double Area { get { return area; } }
public Country(string name, double area)
{
this.name = name;
this.area = area;
}
}
控制器:
public ActionResult ReportViewerPartial()
{
Session["CountriesDatas"] = CountriesProvider.GetCountries(); //Country List
XtraReport1 report = new Q502351.Reports.XtraReport1();
report.DataSourceDemanded += report_DataSourceDemanded;
ViewData["Report"] = report;
return PartialView("ReportViewerPartial");
}