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

Change itemtemplate depending on number odfitems in datasource

1 Answer 44 Views
ListView
This is a migrated thread and some comments may be shown as answers.
vandenbroele
Top achievements
Rank 1
vandenbroele asked on 19 Aug 2011, 02:37 PM
since topic titles can't be edited:

Change itemtemplate depending on number of items in datasource



Hello

If my datasource contains less than 10 entries, the listview needs to display the items in a tiled way (divs with float left), but if I get more results, it should be an ordinary list (just divs).

What would be the best way to accomplish this?

1 Answer, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 24 Aug 2011, 08:39 AM
Hi Vandenbroele,

You can try one of the below approaches:
    - Declare to separate RadListView controls and display one of them depending of the data source records count
    - Define the RadListView entirely in code-behind, on Page_Init. For that purpose, you should define separate classed for the LayoutTemplates and ItemTemplates. And on Page_Init decide which templates shuld the RadListView use.

All the best,
Iana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
ListView
Asked by
vandenbroele
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or