c# - programmatically hooked-up event not firing? -
c# - programmatically hooked-up event not firing? -
i'm creating table containing couple of buttons. these buttons hookup events firing method updating specific database item. somekind of reason event isn't proper hooked-up. method should executed isn't executed @ all. doing wrong
pseudo code:
public void createtable(list<bll> itemlist) { //newtable; foreach (bll item in itemlist) { //newrow; //create multiple cells... tablecell cell = new tablecell(); button button = new button(); button.id = "buttonname" + counter.tostring(); button.text = "update"; button.click += new system.eventhandler(this.updatebutton_click); cell.controls.add(button); //addcelltotablerow } //addrowtotable } public void updatebutton_click(object sender, eventargs e) { //logic sender , update database. //debugger doesn't breakpoint here. }
you need read on asp.net page life cycle.
when create dynamic controls, need recreate them on every post - best done in oninit
event handler.
if not so, objects , attached events not exist, events not fire on them.
c# asp.net events
Comments
Post a Comment