I have an asp placeholder in my page, and I dynamically insert "rows" into it, where each row is a user control.
If the request is a GET request, I load the data from the database and populate as many user controls as needed. I also add the control instances into the session contents.
If the request is a POST request, I first re-create the controls by looking at the session contents, inside of Page_Load(). Afterwards, each button's handler can do whatever extra work it needs to be done, such as add a new row (to the placeholder, the session, and the DB), delete a row (from placeholder, session, and DB), or update an existing row.
I am facing several issues here:
- When deleting rows, sometimes the wrong data is displayed on the screen after the delete, even though the right row was deleted. This is dangerous, because for further deletes we don't know which rows will be affected.
- When adding a new row, sometimes one of the existing rows will have the wrong data in it (specifically data from another existing row)
How can I fix these issues? I am having a hard time even diagnosing the problem. Are these common issues? Am I just doing this completely wrong? What are better ways to accomplish this?