how to find child repeater on page load

Posted by Shanky11 under ASP.NET on 8/21/2014 | Points: 10 | Views : 1250 | Status : [Member] | Replies : 1
<div class="productLeft">
<a runat="server" class="open1 a" id="a" href="?i=1">Bathroom Taps</a>

<ul id="jsddm" style="display: none;" runat="server">
<asp:Repeater ID="rptMenu" runat="server" OnItemDataBound="rptMenu_OnItemBound" Visible="false">
<ItemTemplate>
<li class="hover1">
<asp:LinkButton ID="lnkcategory" runat="server" Text='<%#Eval("Category") %>' OnClick="lnkCategory_Click"></asp:LinkButton>
</li>
<ul>
<asp:Repeater ID="rptChildMenu" runat="server" Visible="false">
<ItemTemplate>
<li class="hover">
<asp:LinkButton ID="lnksubcategory" runat="server" Text='<%#Eval("Subcategoty") %>' OnClick="lnkSubCategory_Click"></asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>

</ul>
</ItemTemplate>
</asp:Repeater>

</ul>
<a runat="server" class="open1 a" id="a1" href="?j=2">Bathroom Accessories</a>
<ul id="Ul1" style="display: none;" runat="server">
<asp:Repeater ID="rptAccessories" runat="server" Visible="false">
<ItemTemplate>

<li class="hover2">
<asp:LinkButton ID="lnkAcategory" runat="server" Text='<%#Eval("Category") %>' OnClick="lnkACategory_Click"></asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>

</div>




Responses

Posted by: Naveenhcl on: 9/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

On What purpose you need to find the child control in page load event..?

You are binding parent control in page load event right..?

Then after onItemDataBound event of repeater you can easily find the child control.

protected void rptParent_OnItemDataBound(object sender,RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rptChild=((Repeater)e.Item.FindControl("rptChild"));
}
}

If your requirement id different then please let me know.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response