I got a dashboard page which includes 4 partial view.
I just need to give data as parameter to partial view from inside the Index.cshtml
.
Here's my Index.cshtml
code (top of the page):
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@using CoreLibrary.Extensions
@using System.Data
@{
Business.ReportBll.DailyParams prms = new Business.ReportBll.DailyParams();
prms.end = DateTime.Now;
prms.start = DateTime.Now.FirstDayOfMonth();
var DataDaily= Business.Report.ReportDaily(prms, true);
HtmlString baslangicBitisTarSpan = new HtmlString((prms.strdate.HasValue ? "<span style='margin-left:5px'>Başlangıç:"
prms.strdate.Value.ToString("dd.MM.yyyy HH:mm")
"</span>" : ""));
}
Middle of the Index.cshtml
, giving parameter to oage
<div >
<div >
@RenderPage("~/Views/Report/_DashDaily.cshtml", new { DataDaily = DataDaily })
</div>
<div >
@RenderPage("~/Views/Report/_DashboardWeek.cshtml")// data will be added here soon
</div>
</div>
</div>
Inside the _DashDaily.cshtml top of
@using CoreLibrary.Extensions
@using System.Data
@{
var k1 = DataDaily;
var k = @DataDaily;
}
Finally the Error is
CS0103: The name 'DataDaily' does not exist in the current context
Its really simple but idk why i couldnt. Will you help me. Thanks
The type of return data
CodePudding user response:
Please try this
inside the _DashDaily.cshtml top of
@using CoreLibrary.Extensions
@using System.Data
@model DataTable//<YOUR Model Class>
@{
var k1 = Model;
}
CodePudding user response:
I solved it like this.
@using CoreLibrary.Extensions
@using System.Data
@{
var DataDaily = @Page.DataDaily;
}