Passing parameter to ObjectDataSource report

2 posts, 0 answers
  1. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2014

    Posted 04 Jan 2016 Link to this post


    I'm trying to create a report programatically in C# using ObjectDataSource.

    I've added a report parameter to the Report, and the parameter bar shows up on the right hand side.

    I'm trying to pass the parameter from the report filer to my GetData class when the user clicks on "Preview" button. Can someone please help?


    We first used the VS Telerik reporting wizard to create a Table report.

                this.RLDS.DataMember = "GetData";
                this.RLDS.DataSource = typeof(Test.TelerikReportLibrary.GenericTableDataSource);

                                new Telerik.Reporting.ObjectDataSourceParameter("location", typeof(string), null));

    namespace Test.TelerikReportLibrary
        public class GenericTableDataSource
            public static List<AssetReportLine> GetData(string location) {
                var resultAssetList = new List<AssetReportLine>();
                // Get data from database
                return resultAssetList;


    We tried to add a parameter so that it displays on the right hand side of the report.
    var reportParameter1 = new Telerik.Reporting.ReportParameter();
    reportParameter1.Name = "location";
    reportParameter1.Text = "Enter Value for Parameter1";
    reportParameter1.Type = Telerik.Reporting.ReportParameterType.Integer;
    reportParameter1.AllowBlank = false;
    reportParameter1.AllowNull = false;
    reportParameter1.Value = "=10";
    reportParameter1.Visible = true;

  2. Stef
    Stef avatar
    3611 posts

    Posted 06 Jan 2016 Link to this post

    Hello Michael,

    The data retrieval method's arguments can be mapped to report parameters. Please consider the example in Using Parameters with the ObjectDataSource Component.
    this.RLDS.DataMember = "GetData";
    this.RLDS.DataSource = typeof(Test.TelerikReportLibrary.GenericTableDataSource);
                              new Telerik.Reporting.ObjectDataSourceParameter("location", typeof(string), "=Parameters.location.Value"));

    The recommended approach for creating report programmatically is to start with the Visual Studio Report Designer. By designing a sample report with test data, the VS Report Designer will generated code in the report's designer.cs(vb) file which can be modified and used at run-time.

    I hope this information is helpful.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top