我在visual studio中创建了很多rdlc报告。我让他们导出excel,pdf,图像和单词。现在我需要在运行时设置参数,用户可以定义某个字段的开始日期和结束日期。那个领域是PSURcvd。我已将参数StartDate和EndDate添加到rdlc“HolbrookReceived”。但我不知道如何将它们分配给PSURcvd字段以及如何在运行时提示日期输入的文本框。我该怎么做?
这是我控制器中的代码。
public ActionResult HolbrookReceivedReport(string id)
{
LocalReport lr = new LocalReport();
string path = Path.Combine(Server.MapPath("~/Report"), "HolbrookReceived.rdlc");
if (System.IO.File.Exists(path))
{
lr.ReportPath = path;
}
else
{
return View("Index");
}
List<TblPSU> cm = new List<TblPSU>();
using (PSU_DatabaseSQLEntities dc = new PSU_DatabaseSQLEntities())
{
cm = dc.TblPSUs.ToList();
}
ReportDataSource rd = new ReportDataSource("HolbrookReceivedDataSet", cm);
lr.DataSources.Add(rd);
string reportType = id;
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>" + id + "</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>1in</MarginLeft>" +
" <MarginRight>1in</MarginRight>" +
" <MarginBottom>0.5in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = lr.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}
这是我的观点
<ul class="nav nav-pills nav-stacked">
<li>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Ramona Holbrook Received <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="@Url.Action("HolbrookReceivedReport", new { id = "PDF" })">PDF</a></li>
<li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Excel" })">Excel</a></li>
<li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Word" })">Word</a></li>
<li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Image" })">Image</a></li>
</ul>
</div>
</li>
答案 0 :(得分:1)