Phani Kumar

Phani Kumar

  • NA
  • 162
  • 23.3k

how to find the parent control from child control event

Jan 20 2021 11:59 AM
Hi,
 
I have datalist control in that i have a link button, where linkbutton is the child control for datalist.
 
I have a linkbutton on click event, in this event how can find the datalist
 
please find the sample code of mine using to find
 
protected void lnkDelete_Command(object sender, CommandEventArgs e)
{
// DataList dlAttachements = (DataList)sender;
WTLinkButton linkbutton = (WTLinkButton)sender;
DataListItem item = (DataListItem)linkbutton.NamingContainer;
//GridEditableItem dataitem = (GridEditableItem)((WTLinkButton)sender).NamingContainer;
//WTLinkButton lnkDelete = dataitem.FindControl("lnkDelete") as WTLinkButton;
DataList dlist = Parent.FindControl("dlAttachements") as DataList;
DataList dataList = item.Parent.FindControl("dlAttachements") as DataList;
 
Thanks in advance for the help

Answers (1)