Accessing parent data in nested repeater, in the HeaderTemplate

后端 未结 5 1162
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 02:42

Simple question, not sure there\'s a simple answer!

So here\'s the code: (I\'ve simplified it a lot to make it easier to read)



        
相关标签:
5条回答
  • 2020-11-30 03:16

    Solution given by Paul didn't work for me, but this did:

    <%# DataBinder.Eval(Container.Parent.Parent, "DataItem.YourProperty")%> 
    
    0 讨论(0)
  • 2020-11-30 03:18

    I have used as below. Two Repeaters act as Parent and Child.below how I get Parent value of ID Column inside Child repeater.

    <%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "ID") %>
    
    0 讨论(0)
  • 2020-11-30 03:22

    I have found the answer actually:

    Use:

    <HeaderTemplate>
        <%# ((RepeaterItem)Container.Parent.Parent).DataItem %>
    </HeaderTemplate>
    
    0 讨论(0)
  • This is an old thread, but it seems proper to add:

    In my case I have 2 nested ASPxGridView controls (DevExpress) and Container.Parent.Parent didn't work.

    To access parent's data item from child, this is what worked for me:

    <%# DataBinder.Eval(Container.NamingContainer.NamingContainer, "DataItem.DbField")%>
    
    0 讨论(0)
  • 2020-11-30 03:31

    If I want to retrieve a property of a parent repeater I typically do this:

    <%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "ThePropertyName")%>
    
    0 讨论(0)
提交回复
热议问题