".ASPX web form page who contains ReportViewer control"
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana" Font-Size="8pt" Height="768px"
ProcessingMode="Remote" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt" Width="1024px">
<ServerReport ReportPath="/REPORTS_FOLDER/REPORT_NAME"
ReportServerUrl="http://YOUR_SSRS_SERVER/reportserver" />
</rsweb:ReportViewer>
</form>
</body>
</html>
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
...
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
var rprtPrms =
(Dictionary) Session["reportParameters"];
foreach (var item in rprtPrms)
{
ReportViewer1.ServerReport.SetParameters(
new List() {
new ReportParameter(item.Key, item.Value.ToString())
}
);
}
}
}
"The action in the controller"
public ActionResult Index()
{
var rprtPrms = new Dictionary();
rprtPrms.Add("MyReportParameter", 6);
Session["reportParameters"] = rprtPrms;
return Redirect("/RprtViewer.aspx");
}
No comments:
Post a Comment