Click here to Skip to main content
15,888,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<pre> <asp:Repeater ID="rptMenu" runat="server" OnItemDataBound="rptMenu_OnItemBound">
        <ItemTemplate>
            <li id="lst" runat="server" class="accordion-group">
                <div class="accordion-heading">
                <a runat="server" id="menuItemlnk" href='#<%#Eval("MenuID") %>' data-parent="#mainSideMenu" data-toggle="collapse" class="accordion-toggle"><span class="item-icon aweso-icon-list-alt"></span><%#Eval("MenuName") %></a>
                </div>
                <ul class="menu" id='<%#Eval("MenuID") %>'>
                    <asp:Repeater ID="rptChildMenu" runat="server">
                        <ItemTemplate>
                    <li class="active"><a runat="server" id="MenuchildItemLnk" href='<%#Eval("URL") %>'>^__i class="fontello-icon-right-dir"><%#Eval("MenuName") %></a></li>
                        </ItemTemplate>
                    </asp:Repeater>
                </ul>
            </li>
            <!-- // item accordionMenu Calendar -->
        </ItemTemplate>
    </asp:Repeater>

how can we find the control MenuchildItemLnk of repeater rptChildMenu?

What I have tried:

i tried to get through this code but error

C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        Repeater rpt = (Repeater)Page.Master.FindControl("rptMenu");
        Repeater Childrpt = (Repeater)rpt.FindControl("rptChildMenu");

        if (Childrpt != null)
        {
            foreach(RepeaterItem item in rpt.Items)
            {
                if(item.ItemType==ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {

                    HtmlAnchor Lnk = (HtmlAnchor)item.FindControl("MenuchildItemLnk");

                    if (Lnk.HRef == "frmExpenseCode.aspx")
                    {
                        string UID = Session["UID"].ToString();

                        string expCode = GetExpCode(UID);
                        txtEcode.Text = expCode;
                    }

                }
            }

        }


    }

}
Posted
Comments
Where is the error, which line? And what is the error?
Afzal Shaikh 31-Dec-16 7:28am    
child repeater is null when execute the code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900