Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databinding Checkbox Lists and Deleted Records in Database

Status
Not open for further replies.

SonJ

Programmer
Oct 24, 2002
166
GB
Hi,

I have an application where I can add, edit and delete items that appear in a checkboxlist. Checkboxlist items are bound to this control from a table in the database. When an item is deleted, it is flagged as such in the database and will not appear for selection.

If a user enters a request on to the system, they need to select an item from the checkboxlist. If before they try to edit the request, the chosen item in the checkboxlist is deleted, then the page displays an error when the user tries to edit the request. The error is as follows:

Object reference not set to an instance of an object.

I know why it does this, I want to know if there is a way around it. At the moment I am binding non-deleted items to the checkboxlist. Any help would be much appreciated.

SonJ
 
I Guess the only way you could do it would be to go back to the database and check that the item still exists (i.e. it doesn't have a flag) before you carry out your code that is giving you the error.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Why not on post back check the database to ensure the record still exists and do the edit, otherwise inform the user the record was deleted?

Patrick Green
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top