I have created following view form to filter results ,
我创建了以下视图表单来过滤结果,
also I have created following aspx web-form to generate report
我也创建了以下aspx web-form来生成报告
Now I want to once I click Generate Report button in view form(1st image) I should be able to pass parameters to text boxes
现在我想在视图窗口(第一张图像)中单击Generate Report按钮后,我应该能够将参数传递给文本框
- Type
- Category
- Subsidary
- Country
- Date
generate results in web-form and show Microsoft report wizard(RDLC) like 2nd image .
以Web表单生成结果并显示Microsoft报表向导(RDLC),如第二张图像。
I have done these things separately, I want to link those together
我已经单独完成了这些事情,我想将它们联系在一起
1 个解决方案
#1
0
1
Create a model with the filter properties but add a datatable for dataset in report.rdlc for example
使用过滤器属性创建模型,但在report.rdlc中为数据集添加数据表
public class paramsModel
{
public string typeRep {get; set;}
public DateTime dateRep {get; set;}
public DataTable dataReport {get; set;}
}
2
In your Controller create the ActionResult for the View
在Controller中为View创建ActionResult
public ActionResult showReport()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult showReport(paramsModel paramsRep)
{
if (ModelState.IsValid)
{
paramsRep.dataReport = LocalData.GetDataFromDb(paramsRep.typeRep, paramsRep.dateRep);
}
return View(paramsRep);
}
3
In your View
在你的视图中
@model yourproyect.models.paramsModel
@{
ViewBag.Title = "Report page";
var settings = new ControlSettings
{
UseCurrentAppDomainPermissionSet = true,
EnableHyperlinks=true
};
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Report filters</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.typeRep , new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.typeRep , ModelMetadata.FromLambdaExpression(model => model.typeRep , ViewData).EditFormatString, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.typeRep )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.dateRep , new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.dateRep , ModelMetadata.FromLambdaExpression(model => model.dateRep , ViewData).EditFormatString, new { @class = "form-control datepicker" })
@Html.ValidationMessageFor(model => model.dateRep )
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@if (Model != null)
{
<div >
@Html.MvcReportViewer("Reports/YourReport.rdlc").ProcessingMode(ProcessingMode.Local).LocalDataSource("DataSet1", Model.dataReport).ControlSettings(settings).Attributes(new { Style = "width:100%; border:none; height: 87vh;" }).Method(FormMethod.Post)
</div>
}
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$('.datepicker').datepicker({
dateformat: "@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower()",
language: "es",
autoclose: true,
showAnim: 'blind',
highlightWeek: true
}); //Initialise any date pickers
</script>
}
#1
0
1
Create a model with the filter properties but add a datatable for dataset in report.rdlc for example
使用过滤器属性创建模型,但在report.rdlc中为数据集添加数据表
public class paramsModel
{
public string typeRep {get; set;}
public DateTime dateRep {get; set;}
public DataTable dataReport {get; set;}
}
2
In your Controller create the ActionResult for the View
在Controller中为View创建ActionResult
public ActionResult showReport()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult showReport(paramsModel paramsRep)
{
if (ModelState.IsValid)
{
paramsRep.dataReport = LocalData.GetDataFromDb(paramsRep.typeRep, paramsRep.dateRep);
}
return View(paramsRep);
}
3
In your View
在你的视图中
@model yourproyect.models.paramsModel
@{
ViewBag.Title = "Report page";
var settings = new ControlSettings
{
UseCurrentAppDomainPermissionSet = true,
EnableHyperlinks=true
};
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Report filters</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.typeRep , new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.typeRep , ModelMetadata.FromLambdaExpression(model => model.typeRep , ViewData).EditFormatString, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.typeRep )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.dateRep , new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.dateRep , ModelMetadata.FromLambdaExpression(model => model.dateRep , ViewData).EditFormatString, new { @class = "form-control datepicker" })
@Html.ValidationMessageFor(model => model.dateRep )
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@if (Model != null)
{
<div >
@Html.MvcReportViewer("Reports/YourReport.rdlc").ProcessingMode(ProcessingMode.Local).LocalDataSource("DataSet1", Model.dataReport).ControlSettings(settings).Attributes(new { Style = "width:100%; border:none; height: 87vh;" }).Method(FormMethod.Post)
</div>
}
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$('.datepicker').datepicker({
dateformat: "@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower()",
language: "es",
autoclose: true,
showAnim: 'blind',
highlightWeek: true
}); //Initialise any date pickers
</script>
}