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

Forums / General Discussions / SP4 Update - DataBinding: 'Telerik.Cms.Engine.Data.CmsContentBase' does not contain a property with the name...

SP4 Update - DataBinding: 'Telerik.Cms.Engine.Data.CmsContentBase' does not contain a property with the name...

7 posts, 0 answered
  1. Webteam
    Webteam avatar
    28 posts
    Registered:
    30 Nov 2009
    07 Oct 2010
    Link to this post

    After upgrading to service pack 4 I am getting the following error in newsview and events wherever I am binding to Meta that we added.

    DataBinding: 'Telerik.Cms.Engine.Data.CmsContentBase' does not contain a property with the name 'metaname'

    sample code...

     <ItemTemplate>
             <li>
                <span class="newslist-date"><asp:Literal ID="Publication_Date" runat="server" Text="{0}" /></span>
                <div class="newslist-content">
                        <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Source") %>' CssClass="newlist-link" Target="_blank"><asp:Literal runat="server" ID="Title" /></asp:HyperLink>
                        <div class="newslist-more"><asp:Literal ID="Author" runat="server" Text="{0}"/></div>

                 
                </div>
             </li>
        </ItemTemplate>



    would generate the error for "Source"

    I have checked the provider and checked that the meta is still in web.config...

     <add key="News.Source" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
     
    Please let me know what else could be the cause of this problem.


    Here is the complete exception:

    [HttpException (0x80004005): DataBinding: 'Telerik.Cms.Engine.Data.CmsContentBase' does not contain a property with the name 'Source'.]
       System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8683885
       System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +92
       System.Web.UI.DataBinder.Eval(Object container, String expression) +93
       System.Web.UI.TemplateControl.Eval(String expression) +43
       ASP.sitefinity_controltemplates_news_inthenewstemplate_ascx.__DataBinding__control5(Object sender, EventArgs e) in c:\sites\PublicSites\Absolute.Com\www.absolute.com\Sitefinity\ControlTemplates\News\InTheNewsTemplate.ascx:14
       System.Web.UI.Control.OnDataBinding(EventArgs e) +91
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +201
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +127
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +478
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +61
       System.Web.UI.WebControls.Repeater.DataBind() +76
       Telerik.Cms.Engine.WebControls.ContentView.CreateChildControls() +4578
       Telerik.News.WebControls.NewsView.CreateChildControls() +21
       System.Web.UI.Control.EnsureChildControls() +102
       System.Web.UI.Control.PreRenderRecursiveInternal() +42
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    07 Oct 2010
    Link to this post
    Hi David,

    You cannot use Eval to get metadata data from IContent object, because the metadata is not a property of the object. The correct way to set NavigateUrl of your HyperLink is overriding the SetItemMetadata method of the control and there you can access the IContent object and get the value by using GetMetaData method. Then you can set this value to NavigateUrl property of the control.

    Another option would adding a Label inside ListPageMaster.ascx external template and setting the ID of the label to "Source". The label should be hidden by div with style display:none. Inside the code behind of the template subscribe for ItemDataBound event and access the HyperLink and your Label. Then set the Text value of the label to the HyperLink NavigateUrl.

    Third option is using MetaMaster

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    18 Oct 2011
    Link to this post
    Hi I've tried setting up something similar to the second option.  I have a label called AuthorSource.  What I want is to have the Author and Source fields output in the form "My Author, My Source" (without the quotes) where My Author is the value of the Author field and My Source is the value of the Source field.  For some reason AuthorSource is coming up empty even though Author and Source have values.

    This is the code in my ListPageMaster.ascx:
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs  e) {       
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
            Literal Author = e.Item.FindControl("Author") as Literal;
            Literal Source = e.Item.FindControl("Source") as Literal;
            Label AuthorSource = e.Item.FindControl("AuthorSource") as Label;
            string authorTrim = Author.Text.Trim();
            string sourceTrim = Source.Text.Trim();
            string separator = authorTrim != "" && sourceTrim != "" ? ", " : "";
             
            AuthorSource.Text = authorTrim + separator + sourceTrim;
        }
    }

    <telerik:CssFileLink ID="CssFileLink1" EmbeddedFileName="Telerik.News.Resources.ControlTemplates.Frontend.newsCommonLayout.css" FileName="" Media="screen" runat="server" />
     
    <asp:HyperLink ID="backLink" runat="server" Text="<%$Resources:GoBack %>"></asp:HyperLink>
    <asp:Repeater ID="repeater" runat="server" OnItemDataBound="repeater_ItemDataBound">
        <HeaderTemplate>
            <ol class="sf_eventsList">
        </HeaderTemplate>
        <ItemTemplate>
            <li>
                <h2 class="sf_eventTitle">
                    <%--<asp:HyperLink ID="fullContent1" runat="server">--%>
                        <asp:Literal ID="Title" runat="server"></asp:Literal>
                    <%--</asp:HyperLink>--%>
                </h2>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="newsTbl">
                  <tr>
                    <td style="width:40%;"><asp:Literal ID="Publication_Date" runat="server" Text="{0}" /></td>
                    <td class="resourceText"><asp:Label ID="AuthorSource" runat="server" /></td>
                  </tr>
                </table>
                <p>
                    <asp:Literal ID="Summary" runat="server" Text=""></asp:Literal>
                </p>
                <p class="sf_readMore">
                    <asp:HyperLink ID="fullContent1" runat="server">
                        <asp:Literal ID="LiteralFS" runat="server" Text="Full story ››"></asp:Literal>
                    </asp:HyperLink>
                </p>
                <asp:PlaceHolder ID="ThumbnailHolder" runat="server">
                    <p class="sf_newsThumbnail"><asp:Image ID="Thumbnail" runat="server" /></p>
                </asp:PlaceHolder>
                <p class="sf_postCategory">
                    <asp:HyperLink ID="Category" runat="server" />
                </p>
                <p class="sf_postTags">
                    <asp:Repeater ID="Tags" runat="server">
                        <ItemTemplate>
                            <asp:HyperLink ID="tagLink" runat="server" />
                        </ItemTemplate>
                    </asp:Repeater>
                </p>
                <div style="display:none;">
                    <asp:Literal ID="Author" runat="server"></asp:Literal><asp:Literal ID="Source" runat="server"></asp:Literal>
                </div>
            </li>
        </ItemTemplate>
        <FooterTemplate>
            </ol>
        </FooterTemplate>
    </asp:Repeater>
    <telerik:Pager ID="pager1" runat="server">
        <LayoutTemplate>
            <asp:Repeater ID="PageRepeaterLinkButton" runat="server">
                <HeaderTemplate>
                    <ol class="sf_pager">
                    <li><asp:LinkButton ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:LinkButton></li>
                </HeaderTemplate>
                <ItemTemplate>
                    <li>
                        <asp:LinkButton ID="SingleItem" runat="server" />
                    </li>
                </ItemTemplate>
                <FooterTemplate>
                    <li><asp:LinkButton ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:LinkButton></li>
                    </ol>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Repeater ID="PageRepeaterHyperLink" runat="server">
                <HeaderTemplate>
                    <ol class="sf_pager">
                    <li><asp:HyperLink ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:HyperLink></li>
                </HeaderTemplate>
                <ItemTemplate>
                    <li>
                        <asp:HyperLink ID="SingleItem" runat="server" />
                    </li>
                </ItemTemplate>
                <FooterTemplate>
                    <li><asp:HyperLink ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:HyperLink></li>
                    </ol>
                </FooterTemplate>
            </asp:Repeater>
        </LayoutTemplate>
    </telerik:Pager>

    Thanks!
    Devin

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2011
    Link to this post
    Hi Devin,

    Check the value of AuthorSource.Text after the last request to it. If the string is not empty then something after ItemDataBound event clears the text. You can put another dummy label and set its value to the AuthorSource.Text to narrow down the issue.

    Regards,
    Ivan Dimitrov
    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. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    18 Oct 2011
    Link to this post
    Hi Ivan,
    I quickly added some code to output AuthorSource.Text to repeater_ItemDataBound event and I'm getting an empty string for each news item.  This is the new code:

    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs  e) {       
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
            Literal Author = e.Item.FindControl("Author") as Literal;
            Literal Source = e.Item.FindControl("Source") as Literal;
            Label AuthorSource = e.Item.FindControl("AuthorSource") as Label;
            string authorTrim = Author.Text.Trim();
            string sourceTrim = Source.Text.Trim();
            string separator = authorTrim != "" && sourceTrim != "" ? ", " : "";
             
            AuthorSource.Text = authorTrim + separator + sourceTrim;
             
            // Output AuthorSource.Text
            Response.Write("\nAuthorSource.Text = " + AuthorSource.Text + "<br />");
        }
    }

    Thanks!
    Devin
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Oct 2011
    Link to this post
    Hi Devin,

    Can  you try to get the value from the metakey and set it again to your Literal control?.

    All the best,
    Ivan Dimitrov
    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
  7. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    25 Oct 2011
    Link to this post
    Hi Ivan,
    I've solved this.  The code I came up with looks like this:

    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs  e) {       
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
            IContent cnt = e.Item.DataItem as IContent;
            Label AuthorSource = e.Item.FindControl("AuthorSource") as Label;
            string authorTrim = cnt.GetMetaData("Author").ToString().Trim();
            string sourceTrim = cnt.GetMetaData("Source").ToString().Trim();           
            string separator = authorTrim != "" && sourceTrim != "" ? ", " : "";
             
            AuthorSource.Text = authorTrim + separator + sourceTrim;
        }
    }

    Thanks!
    Devin
Register for webinar
7 posts, 0 answered