Sitecore: itemlist with ObjectDataSource, Listview and DataPager

For a new project I started working with Sitecore again.

I needed to create a listing of items with paging. I implemented a Listview with a ObjectDataSource and the DataPager control.




    
         <li class="clearfix">
            <a class="thumb" ID="thumnailLink"> 
                
            </a>
            <h2></a></h2>
            <span class="date">  </span>
            
            
     </li>
    
    
        Geen artikelen
    
    
        <ul ID="itemPlaceholderContainer">
            <li ID="itemPlaceholder" />
        </ul>
    
    
        <br />
    


<ul>
  <li class="paging">
        
         
             
                
             
         
        
    </li>
</ul> 





In the code behind I created the public method GetItems which returns a ChildListCollection.


namespace MyNameSpace
{
    public partial class MyUsercontrol: System.Web.UI.UserControl
    {
     
       public Sitecore.Collections.ChildList GetItems()
       {
          return Sitecore.Context.Item.GetChildren();
        }
     }
} 


The PagedControlID property of the datapager control is set to the ID of the Listview.

2 Replies to “Sitecore: itemlist with ObjectDataSource, Listview and DataPager”

Leave a Reply

Your email address will not be published.