Link to Repeater Parental Control DataItem inside user control

I need to put a user control in the template of the repeater controls and reference data from the repeater data source.

I tried (ignore the second cast, which depends on the CMS platform used):

<%# ((EPiServer.Core.PageData)((RepeaterItem)Container.Parent.NamingContainer).DataItem)["PageName"]%>

But this throws the following error: Unable to pass an object of type "ASP.usercontrols_searchcontrols_searchresult_ascx" to enter "System.Web.UI.WebControls.RepeaterItem"

Searchresult_ascx is another user control that contains the actual relay.

+3
source share
3

usercontrol - :

<asp:repeater ... >
  <my:usercontrol containerdata='<%# Container.DataItem %>' ... />
</asp:repeater>

, , PageData, .

+4

, , . , , , Trace = "True" - , . , .

0

I would add the OnItemDataBound event to the repeater and from there bind the corresponding data to the user control.

0
source

Source: https://habr.com/ru/post/1716717/


All Articles