I am pretty new in C# and my English is not so good - sorry in advance if I miss a point.
I tried to build an ASP.NET web site with a ReportService
cont
I really haven't messed with SSRS - but my ASP.NET hat tells me you may want to wrap that stuff in an if (!IsPostBack)
block to keep it from running on the page refresh. My guess is that ReportViewer1.ServerReport.Refresh()
pulls the default values again.
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ReportViewer1.Width = 800;
ReportViewer1.Height = 600;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc =new CustomReportCredentials("administrator", "MYpassworw", "domena");
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.0.1/ReportServer/");
ReportViewer1.ServerReport.ReportPath = "/autonarudzba/listanarudzbi";
ReportViewer1.ServerReport.Refresh();
}
}
i have found the solution for this. you have to set credentials first then you have to set parameter for reportviewer.
rvCommon.ProcessingMode = ProcessingMode.Remote;
rvCommon.ServerReport.ReportServerUrl = new System.Uri("SSRSReportServerURL");
rvCommon.ServerReport.ReportPath = "/Report Parts/CustomerMainReport2" ;
Microsoft.Reporting.WebForms.ReportParameter[] RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[1];
rvCommon.ServerReport.ReportServerCredentials = new ReportCredentials("username", "password", "");
RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("CustomerId", "1");
rvCommon.ServerReport.SetParameters(RptParameters);
rvCommon.ServerReport.Refresh();
I made new function and picked it up in the design view on properties, events, reportViewer. (In selection INIT i)
After that, the page works normally and I can change values for parameters.
Default.aspx now looks like:
</head>
<body>
<form id="form1" runat="server">
<div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" onload="Admir">
</rsweb:ReportViewer>
</div>
</form>
</body>
And Default.aspx.cs looks like this
public void Admir(object sender, EventArgs e)
{
ReportViewer1.Width = 800;
ReportViewer1.Height = 600;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc = new CustomReportCredentials("administrator", "mypass", "domena");
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.0.1/ReportServer/");
ReportViewer1.ServerReport.ReportPath = "/autonarudzba/listanarudzbi";
ReportViewer1.ServerReport.Refresh();
}
protected void Page_Load(object sender, EventArgs e)
{
}
you can use the following code in page load event to give parameters
ReportParameter[] reportParameterCollection = new ReportParameter[1]; //Array size describes the number of paramaters.
reportParameterCollection[0] = new ReportParameter();
reportParameterCollection[0].Name = "ACCMGR"; //Give Your Parameter Name
reportParameterCollection[0].Values.Add("12"); //Pass Parametrs's value here.
ReportViewer1.ServerReport.SetParameters(reportParameterCollection);
ReportViewer1.ServerReport.Refresh();
I hope the this works for you