Search results
PDF

How to get a dataset name in Web API Service

You can get a dataset name in Web API Service when using the *ReportHelper class in our Bold Reports Report Viewer component. You can refer the below code snippet for how to get Dataset name at controller side in ASP.NET and ASP.NET Core.

ASP.NET

Store the jsonResult in local property and use that property in ReportHelper.GetDataSetNames. The following code sample demonstrates to get 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);
    }

ASP.NET Core

Store the jsonResult in local property and use that property in ReportHelper.GetDataSetNames. The following code sample demonstrates to get 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);
    }
Contents
Having trouble getting help?Contact Support
Contents
Having trouble getting help?Contact Support