传参数 在开发面板为RDLC时,选择顶部菜单中的 报表-->报表参数,再使用“添加”按钮加入一个变量名称“v1”,类型为String,这就是要传入数据所要使用的变量 添加完成后,选择报表文件中所添加的TextBox控件,在属性中 常规面板-->值 的后面,选择“fx"按钮,在弹出的面板中,类型选择“参数”,项选择“全部”,在参数中选择此前加入的“v1”,双击“v1”,在上部的语法表达式中显示为“=Parameters!v1.Value”,这就是所要使用的表达式,以等号开头 单击按钮后触发下列事件,加载参数 //加载报表文件 this.ReportViewer1.LocalReport.ReportPath = @"job_apply.rdlc"; //加载参数 ReportParameter rp = new ReportParameter("ch_name", txtChName.Text); this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp }); //刷新显示 this.ReportViewer1.LocalReport.Refresh(); ================================================================================= 动态查询数据 在App_Code中编写函数 public static DataView GetJobApplyReport(string ch_name) { string sql = "select * from job_apply where ch_name='" + ch_name + "'"; return SxWebApp.GetDBData(sql); } 用以上函数创建数据源实例ObjectDataSource, 单击按钮刷新报表 //加载报表文件 this.ReportViewer1.LocalReport.ReportPath = @"job_apply.rdlc"; //刷新显示 this.ReportViewer1.LocalReport.Refresh();
vs2008中自带的MicrosoftReportViewer,传参数、动态查询数据问题
最新推荐文章于 2024-04-25 14:35:04 发布