c# - Asp.net: Page won't refresh after clicking dynamically generated Button controls -


clicking on of dynamically generated button controls indeed call b_click method , delete given user, however, upon deleting page not reload 'new' list of users.

        protected void page_load(object sender, eventargs e)         {           dbdb db = new dbdb();           list<user> users = db.getusers().executetypedlist<user>();            foreach (user u in users)           {             button b = new button();             b.text = u.firstname;             b.click += new eventhandler(b_click);             placeholder1.controls.add(b);            }          }        }         void b_click(object sender, eventargs e)        {            button b = (button)sender;           dbdb.user.delete(x => x.firstname == b.text);         } 

protected void page_load(object sender, eventargs e) {    loadusers(); }  void b_click(object sender, eventargs e) {          button button = (button)sender;    string firstname = button.commandargument;      dbdb.user.delete(x => x.firstname == firstname);     placeholder1.controls.remove(button); }  void loadusers() {      dbdb db = new dbdb();    list<user> users = db.getusers().executetypedlist<user>();     foreach (user user in users) {       button button = new button();                button.commandargument = user.firstname;  // user "id" identify user.       button.text = user.firstname;       button.click += new eventhandler(b_click);       placeholder1.controls.add(button);    } } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -