<cms:CMSRepeater ID="rptTopic" runat="server" SelectOnlyPublished="true" OrderBy="NodeLevel,NodeOrder" ClassNames='<%# CLASS_NAME %>' Path='<%# Path %>'>
爲CLASS_NAME
和Path
值在後端預定義。但我仍然遇到錯誤。
我的代碼有問題嗎?
以下是代碼的全部內容。
<cms:CMSRepeater ID="CMSRepeater1" runat="server" SelectOnlyPublished="true" OrderBy="NodeLevel,NodeOrder" ClassNames='<%# CLASS_NAME %>' Path='<%# Path %>'>
<ItemTemplate>
<div class="col-md-3">
<div class="panel panel-default">
<asp:Image ID="imgTopic" runat="server" Height="200px" Width="100%" ImageUrl='<%# Eval("BackgroundImage") %>' />
<h4><%# Eval("Title") %></h4>
<p><%# Eval("Descriptions") %></p>
<a class="btn" href='<%# Eval("UrlLink") %>'>
<%# Eval("UrlText") %>
</a>
</div>
</div>
</ItemTemplate>
</cms:CMSRepeater>
這是我得到的異常:
Message: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'BackgroundImage'.
Exception type: System.Web.HttpException
Stack trace:
at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName)
at System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
at System.Web.UI.DataBinder.Eval(Object container, String expression)
at System.Web.UI.TemplateControl.Eval(String expression)
at CMS.Base.Web.UI.AbstractUserControl.Eval(String column)
at ASP.inteksoft_webparts_content_topiclisting_ascx.__DataBinding__control3(Object sender, EventArgs e) in C:\Users\yjseow\Desktop\inteksoft svn\trunk\MOT\MOT.Website\Website\CMS\Inteksoft\WebParts\Content\TopicListing.ascx:line 9
at System.Web.UI.Control.OnDataBinding(EventArgs e)
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBind()
at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem)
at System.Web.UI.WebControls.Repeater.AddDataItemsIntoItemsArray(IEnumerable dataSource, Boolean useDataSource)
at System.Web.UI.WebControls.Repeater.PostGetDataAction(IEnumerable dataSource)
at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
at CMS.DocumentEngine.Web.UI.BasicRepeater.CreateControlHierarchy(Boolean useDataSource)
at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.Repeater.DataBind()
at CMS.DocumentEngine.Web.UI.BasicRepeater.DataBind()
at CMS.DocumentEngine.Web.UI.CMSRepeater.DataBind()
at CMS.DocumentEngine.Web.UI.CMSRepeater.ReloadDataInternal(Boolean forceReload)
at CMS.DocumentEngine.Web.UI.CMSRepeater.<>c__DisplayClass3.b__2()
at CMS.Base.Web.UI.ControlsExtensions.CallHandled(Control ctrl, Action func)
基於我後,我檢查了我的列字段名稱是正確的,我懷疑我不能指向正確的異常班級名稱。
一旦我從ClassNames='<%# CLASS_NAME %>' Path='<%# Path %>'>
切換到ClassNames="CMS.Topic" Path="/Shared/Topic/%"
,那麼一切順利。
我試圖讓ClassNames
和Path
成爲動態可控的。
你好。你不需要在最後關閉標籤嗎? – Luke359
這是你的意思嗎? ' cms:CMSRepeater>' – SoYuJe