ASP.NET C# reportviewer 参数
ASP.NET C# reportviewer Parameter
我是report viwer的新手,我想知道如何将select参数传递给report viewer和data source?我需要将开始日期和结束日期传递给数据源以过滤数据并显示在报表查看器中。有人建议吗?
> <rsweb:ReportViewer ID="Log_ReportViewer" runat="server" Height="545px" Width="962px" Font-Names="Verdana" Font-Size="8pt"
> WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
> <LocalReport ReportPath="Reporting\ReportRDLC File\LogReport.rdlc">
> <DataSources>
> <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="Log" />
> </DataSources>
> </LocalReport>
> </rsweb:ReportViewer>
> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InvControlConnectionString %>"
> ProviderName="<%$
> ConnectionStrings:InvControlConnectionString.ProviderName %>"
> SelectCommand="SELECT * FROM logs WHERE log_createDate >= startDate AND log_createDate >= endDate">
> <SelectParameters>
> <asp:QueryStringParameter Name="endDate" QueryStringField="endDate" />
> <asp:QueryStringParameter Name="startDate" QueryStringField="startDate" />
> </SelectParameters>
> </asp:SqlDataSource> </asp:Content>
通过后面的代码,像这样:
ReportParameter[] parameters = new ReportParameter[yournumberofparamaters];
parameters[0] = new ReportParameter("name", value);
parameters[1] = new ReportParameter("name", value);
parameters[2] = new ReportParameter("name", value);
this.Log_ReportViewer.LocalReport.SetParameters(parameters);
我是report viwer的新手,我想知道如何将select参数传递给report viewer和data source?我需要将开始日期和结束日期传递给数据源以过滤数据并显示在报表查看器中。有人建议吗?
> <rsweb:ReportViewer ID="Log_ReportViewer" runat="server" Height="545px" Width="962px" Font-Names="Verdana" Font-Size="8pt"
> WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
> <LocalReport ReportPath="Reporting\ReportRDLC File\LogReport.rdlc">
> <DataSources>
> <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="Log" />
> </DataSources>
> </LocalReport>
> </rsweb:ReportViewer>
> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InvControlConnectionString %>"
> ProviderName="<%$
> ConnectionStrings:InvControlConnectionString.ProviderName %>"
> SelectCommand="SELECT * FROM logs WHERE log_createDate >= startDate AND log_createDate >= endDate">
> <SelectParameters>
> <asp:QueryStringParameter Name="endDate" QueryStringField="endDate" />
> <asp:QueryStringParameter Name="startDate" QueryStringField="startDate" />
> </SelectParameters>
> </asp:SqlDataSource> </asp:Content>
通过后面的代码,像这样:
ReportParameter[] parameters = new ReportParameter[yournumberofparamaters];
parameters[0] = new ReportParameter("name", value);
parameters[1] = new ReportParameter("name", value);
parameters[2] = new ReportParameter("name", value);
this.Log_ReportViewer.LocalReport.SetParameters(parameters);