Change itemtemplate depending on number odfitems in datasource

2 posts, 1 answers
  1. vandenbroele
    vandenbroele avatar
    17 posts
    Member since:
    Sep 2007

    Posted 19 Aug 2011 Link to this post

    since topic titles can't be edited:

    Change itemtemplate depending on number of items in datasource


    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?
  2. Answer
    Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 24 Aug 2011 Link to this post

    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,
    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 >>

Back to Top