How to get a dataset name in Web API Service

To get a dataset name in the Web API Service, store the jsonResult in a local property and call ReportHelper.GetDataSetNames in the OnReportLoaded method of the Bold Reports® Report Viewer controller. The following code snippets show how to get the dataset name at the controller side in ASP.NET and ASP.NET Core.

How do I get the dataset name in ASP.NET?

In ASP.NET, store the jsonResult in a local property and use that property in ReportHelper.GetDataSetNames in the Bold Reports® Report Viewer Web API controller. The following code sample gets the dataset name in the OnReportLoaded method.

    private Dictionary<string, object> _jsonResult;

    //Post action for processing the rdl/rdlc report
    public object PostReportAction(Dictionary<string, object> jsonResult)
    {
        if (jsonResult != null && jsonResult.Keys.Count > 0)
        {
            _jsonResult = jsonResult;
        }

        return ReportHelper.ProcessReport(jsonResult, this);
    }

    public object GetResource(string key, string resourcetype, bool isPrint)
    {
        return ReportHelper.GetResource(key, resourcetype, isPrint);
    }

    //Method will be called when initialize the report options before start processing the report
    [NonAction]
    public void OnInitReportOptions(ReportViewerOptions reportOption)
    {

    }

    //Method will be called when reported is loaded
    [NonAction]
    public void OnReportLoaded(ReportViewerOptions reportOption)
    {
        var datasetName = ReportHelper.GetDataSetNames(_jsonResult, this);
    }

How do I get the dataset name in ASP.NET Core?

In ASP.NET Core, store the jsonResult in a local property and use that property in ReportHelper.GetDataSetNames in the Bold Reports® Report Viewer Web API controller. The following code sample gets the dataset name in the OnReportLoaded method.

    private Dictionary<string, object> _jsonResult;

    //Post action for processing the rdl/rdlc report
    public object PostReportAction([FromBody]Dictionary<string, object> jsonResult)
    {
        if (jsonResult != null && jsonResult.Keys.Count > 0)
        {
            _jsonResult = jsonResult;
        }

        return ReportHelper.ProcessReport(jsonResult, this);
    }

    public object GetResource(string key, string resourcetype, bool isPrint)
    {
        return ReportHelper.GetResource(key, resourcetype, isPrint);
    }

    //Method will be called when initialize the report options before start processing the report
    [NonAction]
    public void OnInitReportOptions(ReportViewerOptions reportOption)
    {

    }

    //Method will be called when reported is loaded
    [NonAction]
    public void OnReportLoaded(ReportViewerOptions reportOption)
    {
        var datasetName = ReportHelper.GetDataSetNames(_jsonResult, this, _cache);
    }