I dynamically create some linkbuttons and assign them the same EventHandler:
lb.Click += new System.EventHandler(engCat_Clicked);
In the engCat_Click event, it sets a static variable to the value of the LinkButton's ID that was clicked:
protected void engCat_Clicked(Object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
string engcatID = lb.ID;
currentEngCatID = engcatID;
}
The problem is that this variable is only set the second time I click on the button. It seems the EventHandler method is only called the second time the event happens.
Has anyone encountered this kind of problem before, or know what might be the cause?
Thanks!