Note: I am using Microsoft Reports in MVC4
I have created a DataSet
named DataSet1.xsd in VisualStudio in which i have added a TableAdapter
named 'st' and in that tableadapter i have created DataTable
named dt1. There are two methods in dt1
GetData()
and Fill(@p0)
.
I have created a new RDLC
report which is binded to that DataSet1
now when i try to generate the report it shows the following error
One or more parameters required to run the report have not been specified.
i dont know how to pass parameter at runtime to report
Controller
public ActionResult Report(string id)
{
var lr = new LocalReport();
var path = Path.Combine(Server.MapPath("~/Reports"), "Report1.rdlc");
if (System.IO.File.Exists(path))
{
lr.ReportPath = path;
}
else
{
return View("Index");
}
var reportType = id;
string mimeType;
string encoding;
string fileNameExtension;
var 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;
var renderedBytes = lr.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}
}
i have tried the following ways to add parameters but finds no success
var param0 = new ReportParameter("p0", "1");
rl.SetParameters(new[]{param0});