Well I have table at my Report.rdl and I want To generate it dinamicly like GridView
Reports.dsReport ds = new dsReport();
Reports.dsReportTableAdapters.sp_PaymentsTableAdapter daInformation =
new dsReportTableAdapters.sp_PaymentsTableAdapter();
try
{ 开发者_开发问答
daInformation .Fill(ds.sp_Procedure
, ID
, Name
, Number
, startDate
, endDate
, payerID);
}
catch { }
DataTable dtPaymentInfo = ds.Tables["sp_Payments"];
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("PeriodStart", startDate.Value.ToString("yyyy-MM-dd HH:mm"));
parameters.Add(new ReportParameter("PeriodEnd", endDate.Value.ToString("yyyy-MM-dd HH:mm"));
foreach(DataTable item in dtPaymentInfo.Rows)
{
for(int i = 0; i < item.Rows.Count; i++)
{
int status = (int)item.Rows[i][2];
string paymentName;
if(status == 0)
paymentName=status.ToString() + " EURO";
if(status == 1)
paymentName=status.ToString() + " DOLLAR";
if(status == 2)
paymentName=status.ToString() + " Pound";
parameters.Add(new ReportParameter("PaymentName", paymentName);
}
}
rpvPaymentInformation.LocalReport.SetParameters(parameters);
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
rds.Value = dtPaymentInfo;
rpvPaymentInformation.LocalReport.DataSources.Clear();
rpvPaymentInformation.LocalReport.DataSources.Add(rds);
rpvPaymentInformation.LocalReport.Refresh();
rpvPaymentInformation.ShowReportBody = true;
This is Page's CodeBehind
And when my Table control generates some datas it populates with [status + " EURO"]
But in database status has 1, 2 values too.
How can I solve this problem? :(
It's still very unclear what you are trying to do, but I noticed that you are adding the parameter PaymentName
to the report parameters multiple times. I'm pretty sure you are just ending up with either the first or last parameter you added to the report and not all three.
It is possible that what you are trying to do is add multiple values to the parameter. If that is what you want, then you are better off including your parameter in a table as part of the datasource of the report. See here for how to use a table as a multiple value parameter: http://www.duttonsoftware.com/2008/09/25/easy-multi-value-parameters-in-sql-server-reporting-services/
精彩评论