Data Source with List

2 posts, 0 answers
  1. Jim
    Jim avatar
    27 posts
    Member since:
    Jun 2008

    Posted 03 May 2010 Link to this post

    I am using the folowing business object as the data source of my report

        class BlendingModel  
            private List<BlendingModelRow> _dataRow = new List<BlendingModelRow>();  
            public DateTime StartDate { get; set; }  
            public DateTime EndDate { get; set; }  
            public List<BlendingModelRow> dataRow { get { return _dataRow; } set { _dataRow = value; } }  

    How do I referrence the items in dataRow on the report.  In the text box on the report I have =dataRow.W5_Runtime.  When I run the report I get an error that W5_Runtime does not exist.  W5_Runtime is a member of dataRow.


  2. Milen
    Milen avatar
    181 posts

    Posted 07 May 2010 Link to this post

    Hello Jim,

    If you need to have a detail section (or table row if you want to bind a table) for each BlendingModelRow in dataRow, then you need to bind the report (or table) directly to the property BlendingModel.dataRow of a BlendingModel instance. Then you will be able to refer to the W5_Runtime of the current row using the expression
    How to bind this way? At design time (in the DataSource wizard) choose as Type the BlendingModelRow so that you may build expressions easier. At runtime (for example in the constructor after the InitializeComponent call) set the DataSource of the generated ObjectDataSource to the real list of rows. Something like:
    var model = new BindingModel();
    this.objectDataSource1.DataSource = model.dataRow;

    However if that is not the case and you want to bind to the model, and manually index in expressions the BlendingModelRows, you will need a simple User Defined Function that may be used as indexer because the expression engine does not support indexing a list. Something like:
    public static object Index(object list, int index)
      if(null == list)
        return null;
      return ((IList)list)[index];

    and use the function in expression like:
    =Index(Fields.dataRow, 0).W5_Runtime
    to refer the first item for example.

    Hope this information helps.

    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
Back to Top