We help IT Professionals succeed at work.

Updating a listview without refreshing it

I have a listview that retrieves its data from an sql database.  The sql database has sql dependency enabled and works great!  The problem I have is when the sql dependency runs, it refreshes the listview and sometime causes a null exception when a user clicks on an item in the listview to pull up the information for that record while the listview refresh is running.  I want to know if there is a way to instead of clearing the listview and adding the items back to the listview can you just add or remove items based on the query ran.  Any help and guidance on this issue is greatly appreciated!!

Thanks in advance,
Russell
Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2014
Commented:
That would require you to loop through the records retrieved from database and compare each item with listview to determine if it has been added or removed or unchanged. This would be slow. I suggest you disable listview while its being refreshed to avoid the error.

Author

Commented:
Thank you for your suggestion!  I will take your suggestion on locking the listview!!  Thanks again!
Most Valuable Expert 2012
Top Expert 2014

Commented:
Glad to help :-)