ECO2 Expression Handles and the ASP.NET Repeater Control

How do we databind the information from the ExpressionHandle or other handle type into the ASP.NET Repeater control? Took a little double take viewing, but Pete Morris kindly helped overcome the issue.

The natural urge from most Delphi Devs is to relate things to the DataSource. Understandable, as our time with Delphi has taught us a lot in that area.

I initially went wrong because I would refer to the Handle list component as the source part for the DataBinder.Eval call, as such (PS this is incorrect and will fail):

DataBinder.Eval(ehLogins, "MyPropertyOrFieldName")

There is a short process to go through to get the repeater control to correctly display the data we want.

1) After you have setup your OCL component (OclPsHandle/ExpressionHandle) with the correct OCL to return your list, right-click on the component and select the menu option "Create Default Columns". In my case this was an expression handle called ehLogins.

ECO2_ExpressionHandle_CreateDefaultColumns.jpg

2) On your Repeater control set the DataSource property to your handle. You can do this at design time through the object inspector or in code. Repeater1.DataSource := ehLogins

3) In your ASPX file, your DataBinder code looks a little different to what we might expect. The Eval call should reference Container.DataItem and then the property you want to display. For example:

DataBinder.Eval(Container.DataItem, "MyPropertyOrFieldName")

You should now have a working Repeater control. The Container.DataItem is the important part, as this references the currently selected Object in the list of objects.

 

Share this article!

Follow us!

Find more helpful articles: