I created a dynamically link buttons, and want to pass the eventhandler to it, but it doesn't work. The function never gets called. My code is below:
Code:LinkButton lbtnEdit = new LinkButton(); protected void Button1_Click(object sender, EventArgs e) { foreach (Controls c in Controls) { if (c is textbox) string sTextBoxID = ((TextBox)(c)).ID; char cLast = sTextBoxID[sTextBoxID.Length - 1]; lbtnEdit.ID = "LinkButton" + cLast; lbtnEdit.Click += new EventHandler(lbtnEdit_Click); DIV.Controls.Add(lbtnEdit); } } } protected void lbtnEdit_Click(object sender, EventArgs e) { LinkButton lbtn = (LinkButton)sender; lbtn.ID.ToString(); AddId.Visible = false ; }


Reply With Quote

