报表查看器,设置参数 [英] Report Viewer, Setting Parameters
本文介绍了报表查看器,设置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<rsweb:ReportViewer ID="ReportViewer2" runat="server" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="800px"
Height="600px" Visible="true">
<LocalReport ReportPath="rdlc\Report5.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="SqlDataSource2" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [m_aom] WHERE [m_month] = @m_month">
<SelectParameters>
<asp:QueryStringParameter Name="m_month" QueryStringField="m_month"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
我不知道如何在后面的C#编码中声明选择参数,请任何帮助?
现在,后面的编码中没有其他相关的编码.
I no idea on how to declare the Select Parameter in the behind C# coding, Please any one help?!
There is not other related coding in the behind coding now.
推荐答案
ConnectionStrings:ConnectionString%>" SelectCommand = " " QueryStringField = " 类型= " /> </ SelectParameters > </ asp:SqlDataSource >
ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [m_aom] WHERE [m_month] = @m_month"> <SelectParameters> <asp:QueryStringParameter Name="m_month" QueryStringField="m_month" Type="Int32" /> </SelectParameters> </asp:SqlDataSource>
我不知道如何在后面的C#编码中声明选择参数,请任何帮助?
现在,后面的编码中没有其他相关的编码.
I no idea on how to declare the Select Parameter in the behind C# coding, Please any one help?!
There is not other related coding in the behind coding now.
在代码隐藏"中尝试此代码格式
Try this Code format in Code Behind
ReportViewer1.LocalReport.DataSources.Add
(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dt.ToList()));
ReportViewer1.LocalReport.ReportPath =
Server.MapPath("_MedicalReimburseReport.rdlc");
ReportViewer1.LocalReport.Refresh();
List<reportparameter> parameters = new List<reportparameter>();
parameters.Add(new ReportParameter("coveredDateFrom", txtFrom.Text));
parameters.Add(new ReportParameter("coveredDateTo", txtTo.Text));
parameters.Add(new ReportParameter("workSiteCode", worksiteCode));
ReportViewer1.LocalReport.SetParameters(parameters);
如果可以的话请尝试...
Hi,
Try this if could help...
ReportDocument crpt = new ReportDocument();
string rptLoc = String.Empty;
DataSet1 ds = new DataSet1();
private void AddParameter(ReportDocument reportDocument, string value, string parameterName)
{
ParameterFieldDefinitions prmDef = reportDocument.DataDefinition.ParameterFields;
ParameterValues prmVal = new ParameterValues();
ParameterDiscreteValue prmDiscreteVal = new ParameterDiscreteValue();
prmDiscreteVal.Value = value;
prmVal.Add(prmDiscreteVal);
ParameterFieldDefinition prmFD = prmDef[parameterName];
try
{
prmFD.ApplyCurrentValues(prmVal);
prmFD.ApplyDefaultValues(prmVal);
}
catch (Exception)
{
Response.Redirect("~\\Login.aspx");
}
}
// Some code here...
rptLoc = CrystalReportSource1.Report.FileName;
crpt.Load(rptLoc);
crpt.SetDataSource(ds);
// Some code here...
AddParameter(crpt, lstReport[0].CardNumber.ToString(), "CardNumber");
// Some code here...
CrystalReportViewer1.ReportSource = crpt;
问候
Regards,
这篇关于报表查看器,设置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文