首先在项目中添加web引用
http://localhost/ReportServer/ReportService.asmx
【the code below】
ReportingService rService = new ReportingService();//创建报表服务实例
rService.Credentials =
System.Net.CredentialCache.DefaultCredentials;//设置默认系统凭据
string historyID = null;
bool forRendering = true;
ParameterValue[] values = null;
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters;
parameters = rService.GetReportParameters//获取报表参数集合
(
"/cfhrreport/pos",
historyID,
forRendering,
values,
credentials
);
ListItem item;
foreach(ValidValue v in parameters[0].ValidValues)//遍历参数的有效值集合
{
item=new ListItem(v.Label ,v.Value );
this.DropDownList1 .Items .Add (item);//填充到一个下拉框
}