 |
|
สวัสดีครับผมลองทำ Report ใน ASP.NET ดู โดยนำข้อมูลจาก CUBE มาออก report แต่มีปัญหาบรรทัดที่ผม comment ไว้ครับ (บรรทัด parametersList.Add()) ช่วยผมดูหน่อยครับว่าเป็นเพราะอะไร ผมมือใหม่ครับ :D
Code (C#)
protected void Button1_Click(object sender, EventArgs e)
{
// ทำงานบน server ไม่ใช่ local
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
// hide parameter และส่งไปยัง control
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://NATTAPONE-IT/Reportserver_SQLSERVER2008");
ReportViewer1.ServerReport.ReportPath = "/InternetSaleCount_ByProduct_ByCustomer";
// การใช้ Reporting Service เราต้องมี 2 parameters คือ DimProduct, DimCustomer
List<string> parametersList = new List<string>();
parametersList.Add(GetParameterValue(CustomerList, "DimCustomerName")); // <=== error
parametersList.Add(GetParameterValue(ProductsList, "DimProductName")); // <=== error
ReportViewer1.ServerReport.SetParameters(parametersList);
// Display report
ReportViewer1.ServerReport.Refresh();
}
Microsoft.Reporting.WebForms.ReportParameter GetParameterValue(CheckBoxList checkListBox, string parameterName)
{
List<string> parameterValues = new List<string>();
foreach (ListItem li in checkListBox.Items)
{
if(li.Selected)
{
if (li.Text == "All")
{
parameterValues.Add(li.Value);
break;
}
else
{
parameterValues.Add(li.Value);
}
}
}
return new Microsoft.Reporting.WebForms.ReportParameter(parameterName, parameterValues.ToArray(), true) ;
}
Tag : ASP.NET, Ms SQL Server 2008, Reporting Service, Web (ASP.NET), C#
|
ประวัติการแก้ไข 2011-12-01 17:09:25 2011-12-01 17:09:58
|
 |
 |
 |
 |
Date :
2011-12-01 17:07:48 |
By :
nottp106 |
View :
1749 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |