Get a reference back to the Repeater's e.Item.DataItem from within sub control's OnClick event
Posted on 2008-11-13
I have a repeater that contains an ImageButton in its ItemTemplate.
I've created a delegate to that ImageButton's OnClick event.
I'm not sure though how to reference the e.Item.DataItem of the current row of the repeater in my OnClick event.
public void rptOrders_ItemDataBound(Object sender, RepeaterItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
// Get a reference to the LinkButton that sits inside this repeater
LinkButton lnkbtnOrder = (LinkButton)e.Item.FindControl("imgbtnOrder");
// Create delegate for the ImageButton's OnClick event
lnkbtnReOrder.OnClientClick += new ImageClickEventHandler(this.imgbtnOrder_OnClick);
Now here's thedelegate's OnClick method where I want to handle stuff for the current roew in the repeater and acces it's DataItem:
public void imgbtnOrder_OnClick(object sender, ImageClickEventArgs e)
//Get a reference here somehow back to the repeater's current e.Item.DataItem