2、建立一新的报表,引用数据集的字段,这里来自两个表
3、在页面中拖入ReportViewer控件,添加上面建立的报表
4、在后台代码的page_load事件中写入
string orderid = "10249";
DataSet myds = new DataSet();
if(this.Request.QueryString["id"]!=null)
orderid=this.Request.QueryString["id"].ToString();
ReportParameter rptParaA = new ReportParameter("POrderID", orderid);
ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rptParaA });
myds = Fih.DBFramework.DbHelperSQL.ExecuteDataSet("select * from orders as a join Customers as b on a.CustomerID=b.CustomerID where a.orderid=" + orderid);
ReportViewer1.Visible = true;
ReportDataSource rds = new ReportDataSource("DataSet1_Orders", myds.Tables[0]);
ReportDataSource rds1 = new ReportDataSource("DataSet1_Customers", myds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.DataSources.Add(rds1);
ReportViewer1.LocalReport.Refresh();