Data Repeater - Dynamic template depending on data

  • Thread starter Thread starter Dunc
  • Start date Start date
D

Dunc

I have a repeater that I need to display one of three different templates,
depending on a status bit in the data (e.g. if status = 0, display a basic
template, 1 = with picture, 2 = with picture + extra text)

Is this possible? If so, does anyone have a link to a good tutorial or
example?

Thanks in advance,

Duncan
 
Hi,

Well you have two choises:
1- Create 3 Repeaters and bind/show the needed one. This is the easiest
solution just that you create two controls that you know for sure you will
not use. Even so I believe this is the way to go.
2- Create the ItemTemplate collection to build the control as needed, this
is more error prone and you will need more code for it.


cheers,
 
Sorry - think I phrased that badly. One list could potentially contain all
three different layouts, at any given location.

Any other thoughts?

Duncan
 
Hi,

It does not matter, the list is the datasource, the repeaters are just the
way you will show it, are the repeaters the one that show it differently.

I still think the idea of having 3 repeaters and showing only the one you
want is the best option

cheers,
 
Back
Top