hojjat.mi
hojjat.mi

Reputation: 1534

How to send parameter to stimulsoft report print action?

I have a report thac create by stimulsoft in asp.net core and in view set this action:

@using Stimulsoft.Report.Mvc;

@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
    Actions =
    {
        GetReport = "GetReport",
        PrintReport = "PrintReport",            
        ViewerEvent = "ViewerEvent"
    }
})

and have 3 action :

public async Task<IActionResult> PrintInsurance(int id)
    {          
       return View();
    }

the id parameter is need to load info for report.

public ActionResult GetReport()
{
var insurance = await _insuranceService.GetInsuranceForEdit(id);
        StiReport report = new StiReport();
        report.Load(StiNetCoreHelper.MapPath(this, 
           "wwwroot/Reports/PrintInsurance.mrt"));

        report.RegData("dt", insurance);
        return StiNetCoreViewer.GetReportResult(this, report);
}

in above action how i can get id??

and then this action for print report:

public async Task<IActionResult> PrintReport()
    {
        //Change State To Printed

        bool result = await _insuranceService.ChangeToPrinted((int)id,User.Identity.Name);
        return StiNetCoreViewer.PrintReportResult(this);

    }

in above action again i need id. how can access to id value???

Upvotes: 0

Views: 2093

Answers (1)

Ehsan Zand
Ehsan Zand

Reputation: 350

Define "ID" as a variable in your report, then try to add this in your code before loading the report:

string ID = "ID";
report.Dictionary.Variables("ID").Value = ID;

Upvotes: 0

Related Questions