我在MVC 4 razor中有一个ssrs报告,我在其中生成了点击搜索参数的报告。生成的第一次报告没有任何问题但是当我点击ssrs报告下一页分页完成但我的搜索参数因整页刷新而空白。我不想刷新整页ssrs的分页时间。我想只刷新ssrs部分。
查看页面(index.html)。以下是我的快照:
ssrs report code:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Emenox.Models.Reports.AptekaReportModel>" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<script runat="server">
protected void Page_Init(object sender, EventArgs e)
{
// Required for report events to be handled properly.
Context.Handler = Page;
}
protected void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack == false)
{
ServerReport report = ReportViewer1.ServerReport;
ReportParameter[] rptParameters = new ReportParameter[14];
rptParameters[0] = new ReportParameter("CompanyId", Model.CompanyId.HasValue ? Model.CompanyId.Value.ToString() : "0", false);
rptParameters[1] = new ReportParameter("YearId", Model.YearId.HasValue ? Model.YearId.Value.ToString() : "0", false);
rptParameters[2] = new ReportParameter("MonthId", Model.MonthId.HasValue ? Model.MonthId.Value.ToString() : "0", false);
rptParameters[3] = new ReportParameter("RegionId", Model.RegionId.HasValue ? Model.RegionId.Value.ToString() : "0", false);
rptParameters[4] = new ReportParameter("RepresentativeId", Model.RepresentativeId.HasValue ? Model.RepresentativeId.Value.ToString() : "0", false);
rptParameters[5] = new ReportParameter("ProductId", Model.ProductId.HasValue ? Model.ProductId.Value.ToString() : "0", false);
rptParameters[6] = new ReportParameter("CompanyName", Model.CompanyName, false);
rptParameters[7] = new ReportParameter("YearName", Model.YearName, false);
rptParameters[8] = new ReportParameter("MonthName", Model.MonthName, false);
rptParameters[9] = new ReportParameter("RegionName", Model.RegionName, false);
rptParameters[10] = new ReportParameter("RepresentativeName", Model.RepresentativeName, false);
rptParameters[11] = new ReportParameter("ProductName", Model.ProductName, false);
rptParameters[12] = new ReportParameter("PartyName", Model.PartyName, false);
rptParameters[13] = new ReportParameter("UserId", Model.UserId.HasValue ? Model.UserId.Value.ToString() : "0", false);
// rptParameters[3] = new ReportParameter("ProductName",Model.ProductName, false);
report.ReportServerCredentials = new MyReportServerCredentials();
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
try
{
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerUrl"].ToString());
ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportPath"].ToString() + "/AptekaReport.rdl";
ReportViewer1.ServerReport.SetParameters(rptParameters);
ReportViewer1.LocalReport.Refresh();
}
catch { };
}
}
[Serializable]
protected class MyReportServerCredentials : IReportServerCredentials
{
public MyReportServerCredentials()
{
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
return null; // Use default identity.
}
}
public System.Net.ICredentials NetworkCredentials
{
get
{
return new System.Net.NetworkCredential(ConfigurationManager.AppSettings["NetworkUserName"].ToString(), ConfigurationManager.AppSettings["NetworkPassword"].ToString(), ConfigurationManager.AppSettings["NetworkDoamin"].ToString());
}
}
public bool GetFormsCredentials(out System.Net.Cookie authCookie,
out string user, out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false; // Not use forms credentials to authenticate.
}
}
</script>
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false" >
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" ZoomMode="PageWidth" SizeToReportContent="True"
runat="server" AsyncRendering="false" ShowFindControls="true"
ProcessingMode="Remote" ShowParameterPrompts="False" Width="100%">
<ServerReport DisplayName="Media Expenses Report" />
</rsweb:ReportViewer>
</form>
controller code :
public ActionResult Index()
{
AptekaReportModel model = new AptekaReportModel();
if (Session["UserId"] != null && Session["RoleName"].ToString() != null)
{
model.UserId = Convert.ToInt32(Session["UserId"]);
model.RoleName = Session["RoleName"].ToString();
model.CompanyList = CommonFunctions.GetCompanyListByUserId(model.UserId.Value, model.RoleName);
model.ProductList = CommonFunctions.GetProductsWithSKU();
//model.ProductList = CommonFunctions.GetProductsByUserId(Convert.ToInt32(Session["UserId"]), Session["RoleName"].ToString());
model.RepresentativeList = CommonFunctions.GetRepresentativeByUserId(Convert.ToInt32(Session["UserId"]), Session["RoleName"].ToString());
model.YearList = CommonFunctions.GetYear();
model.MonthList = CommonFunctions.GetMonth();
model.RepresentativeTypeList = CommonFunctions.GetRepresentativeTypeList();
}
return View(model);
}
/// <summary>
/// Search
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public ActionResult Search(AptekaReportModel model)
{
// AptekaReportModel model = new AptekaReportModel();
model.IsSearch = true;
if (Session["UserId"] != null && Session["RoleName"].ToString() != null)
{
model.UserId = Convert.ToInt32(Session["UserId"]);
model.RoleName = Session["RoleName"].ToString();
model.CompanyList = CommonFunctions.GetCompanyListByUserId(model.UserId.Value, model.RoleName);
//model.ProductList = CommonFunctions.GetProductsByUserId(Convert.ToInt32(Session["UserId"]), Session["RoleName"].ToString());
// model.RepresentativeTypeList = CommonFunctions.GetRepresentativeTypeList();
// model.RepresentativeList = CommonFunctions.GetRepresentativeByUserId(Convert.ToInt32(Session["UserId"]), Session["RoleName"].ToString());
}
model.YearList = CommonFunctions.GetYear();
model.MonthList = CommonFunctions.GetMonth();
model.ProductList = CommonFunctions.GetProductsWithSKU();
// model.ActionStatus = true;
// if (Session["ProductList"] != null)
//{
// model.ProductList = Session["ProductList"] as List<SelectListItem>;
//}
if (ModelState.IsValid)
{
if (model.CompanyId != null)
model.CompanyName = CommonFunctions.GetCompanies().Where(x => x.Value == Convert.ToString(model.CompanyId)).SingleOrDefault().Text;
if (model.YearId != null)
model.YearName = CommonFunctions.GetYear().Where(x => x.Value == Convert.ToString(model.YearId)).SingleOrDefault().Text;
if (model.MonthId != null)
model.MonthName = CommonFunctions.GetMonth().Where(x => x.Value == Convert.ToString(model.MonthId)).SingleOrDefault().Text;
//if (model.RegionId != null)
// model.RegionName = CommonFunctions.GetRegionList().Where(x => x.Value == Convert.ToString(model.RegionId)).FirstOrDefault().Text;
if (model.RepresentativeId != null)
model.RepresentativeName = CommonFunctions.GetMRs().Where(x => x.Value == Convert.ToString(model.RepresentativeId)).SingleOrDefault().Text;
if (model.ProductId != null)
model.ProductName = CommonFunctions.GetProductsWithSKU().Where(x => x.Value == Convert.ToString(model.ProductId)).SingleOrDefault().Text;
}
else
{
model.IsSearch = true;
}
return View("Index", model);
}
答案 0 :(得分:0)
{{1}}
将div放在要查看报告的视图中。
答案 1 :(得分:0)
将报告放在iframe中。这会将您的视图与报告分开。因此,单击报告的分页按钮不会影响视图中显示的搜索参数。