This is a migrated thread and some comments may be shown as answers.

Data Source with List

1 Answer 416 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 03 May 2010, 08:53 PM
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.

Thanks,

Jim

1 Answer, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 07 May 2010, 09:32 AM
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
=Fields.W5_Runtime
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.

Greetings,
Milen
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.
Tags
General Discussions
Asked by
Jim
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Share this question
or