Implementing design-time databinding

Design-time support for ObjectLists

1. Implement IComponent for ObjectListBase. This is necessary to be able to use it in the toolbox.

2. Add [Browsable(false)] for several ObjectCollectionBase properties (Count, IsReadOnly, SyncRoot etc), so that they won't appear in the property grid.

At this point you should be able to add the xxxList objects to your toolbox, drag them onto you WebForm, and use it as the DataSource for your Datagrid or any other control.

3. Implement ITypedList for xxxList in your template. This is required to use it as a DataSource for a WinForms DataGrid. Without it, you won't be able to use TableStyles other than default. Return String.Empty from GetListName and return the list of bindable properties from GetItemProperties.

4. Add a few methods with functionality similar to DataAdapter's Fill method. The idea is that you don't create an xxxList object with a factory. Instead, it's created at the initialisation stage with a default constructor, and later you just fill it with a list of entities. I have added a Load method to my template that simply loads everything from an IList (similar to one of the constructors). Don't forget to call OnListChanged so that your bound controls know that you have loaded something.

Design-time support for Entity objects.

I propose using a business facade object and load the underlying entity into a public field. This object would implement IComponent and maybe IEditable and have a default constructor. Must expose same properties as the entity object.

Comments?

ulu

Labels

 
(None)