Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to access parent datalist's label text from child datalist control: ImageButtom click event.
XML
<div>
        <asp:DataList ID="DataList1" runat="server">
        <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <div>
            <asp:DataList ID="DataList2" runat="server">
                <asp:ImageButton runat="server">
                </asp:ImageButton>
            </asp:DataList>
        </div>
        </ItemTemplate>
        </asp:DataList>
    </div>
Posted

1 solution

Please see: https://msdn.microsoft.com/en-us/library/system.web.ui.control.parent%28v=vs.110%29.aspx[^].

In your case, this is making several step of taking a parent until you reach the control you are interested it.

Alternatively, you can simply find the control instance you need id and cast it to the expected control type.

—SA
 
Share this answer
 
v2
Comments
Karmesh_Madhavi 2-Jun-15 3:43am    
can't work, did you get example.
Sergey Alexandrovich Kryukov 2-Jun-15 10:18am    
I have no idea what do you mean by "can't work". If something can't work in your code, please show it.
If you simply don't understand this simple answer, please explain what exactly.
—SA

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