简体   繁体   中英

how do i get my dynamic controls for updating database rows to go away when i delete the corresponding row from the DB

Ok so basically my situation is this: i have a button to search a database. when you click the button I call a function (createRows()) that gets the data from the DB and for each row creates a user control that i made and populates its data with the data from the DB. i also call createRows() in the Page_Load function so that the controls will persist.

inside my usercontrol there is a delete button which in the user control's code behind C# file deletes that row of the DB. this all works fine but i have to hit the search button again for the user control to go away and im wondering why it wont actually go away on its own since i am calling createRows() in the Page_Load anyways?

My guess would be viewstate is caching the results. Set EnableViewState="false" on the control with the rows.

ok i think i might have figured it out i found this tutorial:

http://www.codeproject.com/KB/user-controls/Page_UserControl.aspx

and then i did the usercontrol to page communication and called createRows() from the usercontrol in addition to having it called in Page_Load. seems to be working, any other comments or suggestions are welcome though

thanks,

Leo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM