1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / "Error

"Error

6 posts, 0 answered
  1. Vaibhavi
    Vaibhavi avatar
    13 posts
    Registered:
    13 Oct 2011
    28 Oct 2011
    Link to this post

    Look at my code below:
    ----------------------------------------------------------
    1) MasterListView.ascx

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Sitefinity, Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" TagPrefix="sf" %>
    <%@ Register Assembly="Telerik.Sitefinity, Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
    <%@ Register Assembly="Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>


    <h1>Testimonials</h1>


    <telerik:RadListView ID="TestimonialsList" 
    ItemPlaceholderID="ItemsContainer" GroupPlaceholderID="GroupContainer" GroupItemCount="3" runat="server" 
    EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
        <LayoutTemplate>
            <div class="Testimonials">
                <asp:PlaceHolder ID="GroupContainer" runat="server" />
            </div>
        </LayoutTemplate>
        <GroupTemplate>
            <div class="row">
                <asp:PlaceHolder ID="ItemsContainer" runat="server" />
            </div>
        </GroupTemplate>
        <ItemTemplate>
            <div class="column-small">
                <div class="block">
    <h3><sf:DetailsViewHyperLink ID="DetailsViewHyperLink" TextDataField="Title" ToolTipDataField="Description" runat="server" /></h3>
    <testimonial>
    <sf:FieldListView ID="ClientName" runat="server" Text="{0}" Properties="ClientName" /><br />

    <sf:FieldListView ID="TestimonialText" runat="server" Text="{0}" Properties="TestimonialText" />
    </testimonial>
    </div>
            </div>
        </ItemTemplate>
    </telerik:RadListView>


    <sf:Pager id="pager" runat="server" />
    ----------------------------------------------------------
    2) MasterListView.cs

    namespace Testimonials.PublicControls
    {
        public class MasterListView : ViewBase
    {
    #region Override Template Properties
    protected override string LayoutTemplateName
    {
    get { return null; }
    }


    public override string LayoutTemplatePath
    {
    get
    {
                    var path = TestimonialsModule.TestimonialsVirtualPath + layoutTemplateName;
    return path;
    }
    set
    {
    base.LayoutTemplatePath = value;
    }
    }
    #endregion


            private TestimonialsManager manager;
            protected TestimonialsManager Manager
            {
                get
                {
                    if (this.manager == null)
                        this.manager = TestimonialsManager.GetManager(this.Host.ControlDefinition.ProviderName);


                    return this.manager;
                }
            }






    #region Control References
    protected internal virtual RadListView TestimonialsListControl
    {
    get
    {
                    return this.Container.GetControl<RadListView>("TestimonialsList", true);
    }
    }


    protected internal virtual Pager Pager
    {
    get
    {
    return this.Container.GetControl<Pager>("pager", true);
    }
    }
    #endregion


    #region Methods




    protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition)
    {
                try
                {
                    // ensure a valid definition is passed
                    var masterDefinition = definition as IContentViewMasterDefinition;
                    if (masterDefinition == null) return;


                    // retrieve Testimonials from the manager
                    var manager = TestimonialsManager.GetManager(this.Host.ControlDefinition.ProviderName);
                    var query = manager.GetTestimonials();


                    // modify pager based on query results
                    int? totalCount = 0;
                    int? itemsToSkip = 0;
                    if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
                        itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);


                    // culture for Urls in pager
                    CultureInfo uiCulture = null;
                    if (Config.Get<ResourcesConfig>().Multilingual)
                        uiCulture = System.Globalization.CultureInfo.CurrentUICulture;


                    // check for additional filters set by the definition
                    var filterExpression = String.Empty;


                    // modify the query with everything from above
                    query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
                        query,
                        filterExpression,
                        masterDefinition.SortExpression,
                        uiCulture,
                        itemsToSkip,
                        masterDefinition.ItemsPerPage,
                        ref totalCount);
                    this.IsEmptyView = (totalCount == 0);


                    // display results
                    if (totalCount == 0)
                        this.TestimonialsListControl.Visible = false;
                    else
                    {
                        this.ConfigurePager(totalCount.Value, masterDefinition);
                        System.Collections.Generic.List<Testimonial> list = query.ToList();
                        this.TestimonialsListControl.DataSource = list;
                    }
                }
                catch(Exception ex) {  }
    }


    protected virtual void ConfigurePager(int virtualItemCount, IContentViewMasterDefinition masterDefinition)
    {
    if (masterDefinition.AllowPaging.HasValue &&
    masterDefinition.AllowPaging.Value &&
    masterDefinition.ItemsPerPage.GetValueOrDefault() > 0)
    {
    this.Pager.VirtualItemCount = virtualItemCount;
    this.Pager.PageSize = masterDefinition.ItemsPerPage.Value;
    this.Pager.QueryParamKey = this.Host.UrlKeyPrefix;
    }
    else
    {
    this.Pager.Visible = false;
    }
    }
    #endregion


            internal const string layoutTemplateName = "Testimonials.Resources.Views.MasterListView.ascx";
    }
    }
    --------------------------------
    When I drag and drop this control it gives me error "Error parsing the template" in sitefinity backend editor. And I dont get any testimonial binded in telerik:RadListView. I just get "<h1>Testimonials</h1>" in output.

    When I debug below lines, I found "list"  contains true data. but it doesn't show in RadListView.

    System.Collections.Generic.List<Testimonial> list = query.ToList();
     this.TestimonialsListControl.DataSource = list;


    Where I am doing wrong?
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    02 Nov 2011
    Link to this post
    Hi Vaibhavi,

     After setting the DataSource of the RadListView, you will have to call DataBind in order to bind the collection to the ListView:

    System.Collections.Generic.List<Testimonial> list = query.ToList();
     this.TestimonialsListControl.DataSource = list;
    this.TestimonialsListControl.DataBind();
    If this doesn't solve your issue, please get back to me. Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Vaibhavi
    Vaibhavi avatar
    13 posts
    Registered:
    13 Oct 2011
    03 Nov 2011
    Link to this post
    Now it gives me error "Object reference not set to an instance of an object." when I drag and drop the control from sitefinity backend. When I debug it, it gave an exception "This control must be hosted by ContentView control or one that derives form it."
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    07 Nov 2011
    Link to this post
    Hi Vaibhavi,

    I looked through your code and I didn't find anything disturbing. Can you please send me the whole control so I can test it here locally and see where the error is thrown and what is causing the problem?
    Looking forward to hearing your answer.

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Vaibhavi
    Vaibhavi avatar
    13 posts
    Registered:
    13 Oct 2011
    17 Nov 2011
    Link to this post
    How to send you file? Here only option available is for attaching image file.
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Nov 2011
    Link to this post
    Hello Vaibhavi,

     Can you upload it somewhere I can download it from - for example rapidshare or similar hosting provider (or open a support ticket) ?

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered