I develop MVC project and I add report using aspx page and it view in Razor page (@Html.Partial("ReportViwerASPX"))
when i view report page load code excute but button click not working, please Help
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" AutoEventWireup="true" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
List MulLocSales = null;
using (ERPReporting.MultiLocaSalesEntities db = new ERPReporting.MultiLocaSalesEntities())
{
ddlLocations.DataSource = db.sp_getBranchers();
ddlLocations.DataBind();
MulLocSales = db.Database.SqlQuery("sp_MultiLocation_SalesReport @LocationID, @FromDate, @ToDate",
new System.Data.SqlClient.SqlParameter("@LocationID", ddlLocations.SelectedValue),
new System.Data.SqlClient.SqlParameter("@FromDate", DateTime.Now),
new System.Data.SqlClient.SqlParameter("@ToDate", DateTime.Now)).ToList();
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/MultiLocSales.rdlc");
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource rds = new ReportDataSource("MultiLoctSales", MulLocSales);
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
List MulLocSales = null;
using (ERPReporting.MultiLocaSalesEntities db = new ERPReporting.MultiLocaSalesEntities())
{
MulLocSales = db.Database.SqlQuery("sp_MultiLocation_SalesReport @LocationID, @FromDate, @ToDate",
new System.Data.SqlClient.SqlParameter("@LocationID", ddlLocations.SelectedValue),
new System.Data.SqlClient.SqlParameter("@FromDate", DateTime.Now),
new System.Data.SqlClient.SqlParameter("@ToDate", DateTime.Now)).ToList();
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/MultiLocSales.rdlc");
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource rds = new ReportDataSource("MultiLoctSales", MulLocSales);
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.