Zahra
Zahra

Reputation: 41

Click on an 'image button' in a repeater in asp.net

I have a repeater and there is an image button in each row of this.

By clicking on each Image button ,I should get the Id of respective row but I don't Know how to manage the click event of this image button in repeater.

Upvotes: 1

Views: 3864

Answers (2)

palaѕн
palaѕн

Reputation: 73906

Try this:

ASPX

<asp:LinkButton OnCommand="lbRemove_Command" CommandArgument='<%# Eval("Key")%>' CommandName="Remove" runat="server">

Code Behind

protected void lbRemove_Command(object sender, CommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "Remove":
            string ca = e.CommandArgument.ToString();
            break;
    }
}

Upvotes: 5

Adil
Adil

Reputation: 148120

You need to use ItemCommand event of repeater. You may also look in to ItemDataBound for custom actions on while binding data source.

Upvotes: 1

Related Questions