Nested repeater: How do nested repeater columns reference external repeater columns?
That is to say, I want to reference the value of an external repeater column in the repeater itemtemplete.
<! -- Start parent repeater -->
<Asp: repeater id = "parent" runat = "server">
<Itemtemplate>
<B> <% # databinder. eval (container. dataitem, "au_id") %> </B> <br>
<! -- Start child repeater -->
<Asp: repeater id = "child" datasource = "<% # (datarowview) container. dataitem)
. Row. getchildrows ("myrelation") %> "runat =" server ">
<Itemtemplate>
<% # Databinder. eval (container. dataitem, "[\" title_id \ "]") %> <br>
<% # Databinder. eval (container. dataitem, "au_id") %> ************************
</Itemtemplate>
</ASP: repeater>
<! -- End Child repeater -->
</Itemtemplate>
</ASP: repeater>
<! -- End parent repeater -->
How to Implement the effect of the top-side ** * ** line? If you follow the preceding method, an error will occur.
Step 1:
Declare a variable in the background code of the page:
Protected object parentdataitem; // note that the object is protected.
Step 2:
Then process the itemdatabound event of the parent control:
Private void parent_itemdatabound (Object sender, system. Web. UI. webcontrols. repeateritemeventargs E)
{
Parentdataitem = E. Item. dataitem;
}
Step 3:
Set
<% # Databinder. eval (container. dataitem, "au_id") %> ************************
Changed:
<% # Databinder. eval (parentdataitem, "au_id") %> ************************