My problem is that I dynamically create a table where each cell includes a linkbutton, that when clicked is supposed to remove that cell from the table. (It is i bit more complex than that but I will not go into those details, just saying that a workaround will not do) I have read a few post on this and it usually is mentioned that the control has too be (re)made in page load or before. I have tried to run the method that runs setCellContent from both page load and page init and pre init but the _lnkBntRemoveSlotFromTable_Click method is never called as the linkbuttons are clicked. And I am beginning to wonder there is something else wrong than just when the controls are created/recreated.
For each cell the table consist of, this is what is done:
private TableCell setCellContent(string day, DateTime timeOfDay){
TableCell newCell = new TableCell();
LinkButton lb = new LinkButton();
lb.ID = (++global_counter_id).ToString();
lb.Text = timeOfDay.ToShortTimeString();
lb.CommandArgument = timeOfDay.ToString();
lb.Command += new CommandEventHandler(_lnkBntRemoveSlotFromTable_Click);
newCell.Controls.Add(lb);
return newCell;
}
The method I want to be called:
public void _lnkBntRemoveSlotFromTable_Click(object sender, CommandEventArgs e)
{
//1. Make changes to the table
}
But the method is never called.