1.请问下 AcitveReport.Parameters 这个能动态赋值吗? 有实际例子吗?
2.以下是我绑定数据源的代码,现在我着需要根据页面传递的参数来绑定数据源
例如: DataTable tb = DBContext.ExecuteDataTable("SELECT Name,Sex,Age FROM Student");
前台传递一个id的参数 ,DataTable tb = DBContext.ExecuteDataTable("SELECT Name,Sex,Age FROM Student where id="+id);
根据不同的id获取不同的数据源 ,使用ajax 后 直接跳过pageDocument.LocateDataSource ,无法绑定,请问怎么通过参数来绑定不同数据源
public ActionResult Index()
{
GetReport();
return View();
}
public void GetReport()
{
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/PageReport1.rdlx")));
PageDocument pageDocument = new PageDocument(report);
System.Action<object, LocateDataSourceEventArgs> action = new Action<object, LocateDataSourceEventArgs>(Document_LocateDataSource);
pageDocument.LocateDataSource += (sender, args) =>
{
action(sender, args);
};
ViewData.Model = report;
}
private void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
{
List<Student> list = new List<Student>();
//
DataTable tb = DBContext.ExecuteDataTable("SELECT Name,Sex,Age FROM Student");
foreach (System.Data.DataRow row in tb.Rows)
{
Student stu = new Student();
stu.Name = row["Name"].ToString();
stu.Sex = row["Sex"].ToString();
stu.Age = row["Age"].ToString();
list.Add(stu);
}
int ss = args.Report.Parameters.Count();
args.Data = list;
}
|
|