I have checkbox list bind to a Business Object Collection of List<>. When an item is checked in my checkbox list, I want to mark the selected business object as dirty.
- How can I fetch the current business object on row click and change its property?
- Also, ho开发者_如何学运维w would this shape in a multi-user environment?
This is really a question about concurrency: How do you have multiple users modifying the same business objects and be confident each of their edits will be saved successfully.
If you are storing your objects in the cache, you can create a partial object to include a "IsDirty" boolean property. As an item is checked, you set the IsDirty property of the relevant object to true.
There are many ways to handle concurrency and one way you can try is to check the IsDirty property when an item is checked. If the property is false, you set the property to true. If the property is already true, you send back an error to the user. Once the object is saved, you reset the IsDirty property back to false.
Things can get more and more complicated as you try to get more sophisticated with the rules you create for saving your objects.
You can store the list in view-state/session-state/cache or re-fetch from database on post-back then you can mark business object based on index. Personally, I will choose to get business object list via a wrapper method that will look it into cache and if not there then fetch it from database - that would allow to have small cache expiration time.
In multi-user scenario, it will depend upon how you are managing the concurrency. See this article for quick-start on concurrency in ASP.NET.
精彩评论