I have the following repeater, with some div containing information and an ImageButton
. On click of the ImageButton
I would like to retrieve the DataBinder.Eval
which contains the "ID"
<asp:Repeater ID="RptPendingRequests" runat="server" onitemcommand ="RptPendingRequests_ItemCommand">
//other divs here
<div class="LabelCustomShort" style="font-size:10px"><%#DataBinder.Eval(Container.DataItem, "ID")%></div>
<asp:ImageButton runat="server" ID="btnPrint" ImageUrl="~/Images/print.gif" onclick="btnPrint_Click" /></div>
//other divs here
<asp:Button runat="server" ID="btnSubmit" Text="Submit" style="float:right;" onclick="btnSubmit_Click" />
</asp:Repeater>
On ImageButton click I would like the retrieve the id of the item on which the image button was clicked and send it to another method, as below.
protected void btnPrint_Click(object sender, RepeaterItemEventArgs e)
{
var id = e.Item.FindControl("Id") as Label;
DefaultClass.createPDF(Convert.ToInt32(id));
}
However since it is an image button RepeaterItemEventArgs
can only be ImageClickEventArgs
since its an image button and thus I don't know how I can retrieve the id exactly.