user1017882
user1017882

Reputation:

LinkButton click event not firing

I bind the click event handler server-side, and pass some additional parameters. This binding is done as part of a repeater data bound event. When I click the LinkButton the event handler's never fired. Can't work out why:

lnkUp.Click += (lnkSender, eventArgs) => { lnk_Click(lnkSender, eventArgs, int1, int2, string1); };

(I've checked lnkUp is not null etc.).

The event handler:

 void lnk_Click(object sender, EventArgs e, Int32 int1, Int32 int2, String string1)
 {
      //Do something fantastic
 }

In case you're wondering about the mark-up:

<asp:LinkButton ID="lnkUp" runat="server" Text="SomeText"/>

Upvotes: 0

Views: 1568

Answers (1)

Aghilas Yakoub
Aghilas Yakoub

Reputation: 28970

You try associate click event handler in ItemCreated event, not in ItemDataBound. (Best practise)

And adjust your bind just in ! isPostBack section , in order to don't erase your registered event.

void Repeater_ItemCreated(Object Sender, RepeaterItemEventArgs e) 
{
   .....
}

       

Upvotes: 3

Related Questions