tags:

views:

14

answers:

2

Hi,

I am in situation where I need to bind multiple types to a single repeater.

Say for example I have 2 types in different namespaces

  1. abc.businessLayer.Type_A [properties - Name(string), Country(string)]

  2. xyz.businessLayer.Type_B [properties - FirstName(string), Location(string)]

Now I need to bind the repeater with the combined results of above 2 type collection with the repeater column names "Full Name" and "Country".

I am planning to add a new Type_C.cs in the application layer and iterate the A and B type collection to assign the properties in C and finally bind the repeater with Type_C.

Can someone let me know if there is better way to go with such kind of issue?

A: 

You should write a method that returns a datatable of a combination of the 2 different collections and bind to that method. Ideally this would sit in the BLL in an n tier application

Ben Robinson
where should I write the method, I mean Type_A or Type_B? More over this is not going to be used in other application layers.
Krishna
Neither. Type_A and Type_B are essentialy DTOs by the sound of it. If you have no better place to do it, create a private method in your code behind page. That way if you add a third type later, you just modify this method slightly and everything else still works.
Ben Robinson
A: 

If this data is coming from some database, then return it the way you want to display on the UI. You should probably have a new class/entity that contains the properties for the fields you need to show in the control. It should also have some field/property that help for unique identification of a record.

danish