I'm constructing a LinkButton from my codebehind, and I need to assign the onclick to a method, and pass a parameter with it too. I have this so far:
LinkButton lnkdel = new LinkButton();
lnkdel.Text = "Delete";
The method I want to pass it to looks like this:
protected void delline(string id)
{
}
Well you can't pass it to that method, you need to assign the click event delegate to a method capable of handling it.
Like this:
Assign the click event like any event:
If you want to pass an argument, use CommandArgument, and you'll need a different delegate:
And then:
BTW if you're on >= C#3, you can also use the coolness of anonymous methods:
The function prototype for this event is:
Assign it with: