Posts

Showing posts from April, 2011

Registering Events and creating controls dynamically in ASP.NET

Image
     Hi fellows,   yesterday I spend 4 hours straight, trying to register a simple click event of a series of dynamically created LinkButtons using ASP.NET (C#), I was unable to do that, as the event was not triggering, I was creating the instances of the Linkbutton every time the pageload event was called but all in vain. I was trying to do something like this: foreach (DataRow ddrList in dsCouseList.Tables[0].Rows) { trow = new TableRow(); tcell = new TableCell();     LinkButton btnremove = new LinkButton() { ID = ddrList[ "linkfield" ].ToString(), Text = "Remove" }; btnremove.Click += new EventHandler(btnremove_Click); tcell.Controls.Add(btnremove); trow.Cells.Add(tcell); tcell = new TableCell(); tcell.Controls.Add( new Label { Text = ddrList[ "buyerdescription" ].ToString(), ID= "descr" }); trow.Cells.Add(tcell); tblConfirm.Rows.Add(trow); }   The thing I just missed and got stuck was when I assigned an ID (ID="descr&quo