RadListView Shows default ItemTemplate in list even though Setting OnItemDataBound

2 posts, 0 answers
  1. Simon
    Simon avatar
    25 posts
    Member since:
    Jul 2011

    Posted 01 Jul 2012 Link to this post


    I call a method OnItemDatabound that loads a Control for the ItemTemplate. This works fine, however always at the top of the list the default ItemTemplate from the Markup shows?
    Why is my default ItemTemplate showing in my list??
    I always see the default "THIS IS THE DEFAULT TEMPLATE" at the top of my list and then the real list items display below that.
    If I remove the <ItemTemplate> Then I see the contents of the EmptyDataTemplate only, and If I remove that my list becomes empty all together?

    <telerik:RadListView ID="rlvJobsListPage" runat="server" ItemPlaceholderID="phJobsList" DataSourceId="objJobList"
        OnItemDataBound="rlvJobsListPage_ItemDataBound" AllowCustomPaging="true" AllowPaging="true" PageSize="20" AllowSorting="True">
            <div id="searchList">
                <div id="phJobsList" runat="server">

            No records found
    protected void rlvJobsListPage_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        // Set each bound item to status "Loaded"
        if (e.Item is RadListViewDataItem)
            RadListViewDataItem thisDataItem = (RadListViewDataItem)e.Item;
            Job thisListing = (Job)thisDataItem.DataItem;
            //Determine which template to get from cache
            Templating listingTemplate = Templating.GetTemplateForListing(thisListing.ListingTemplate);
            rlvJobsListPage.ItemTemplate = Templating.Render_ITemplate(listingTemplate.TemplatePath, TemplateType.Summary, this);
  2. Marin
    Marin avatar
    1057 posts

    Posted 04 Jul 2012 Link to this post


     The ItemDataBound event is too late to assign a template because the first item from the ListView is already created there with the default template. In order to work correctly the template should be assigned earlier in the page life-cycle - such as Init or OnLoad events.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top