I think you should take a look at the BugBase application, with the search feature in particular. The SearchCriteria class is able to store multiple "categories" (features, priorities and so on) which are then sent to the database. Inside a stored procedure, a Split method is used to split each item and use it in a query.
The SearchCriteria class uses a comma separated string for the items, but you could also use a generics List(Of Integer) to store the categories. E.g.:
Public Class BlogEntry
Private _Categories As List(Of Integer)
Public ReadOnly Property Categories() As List(Of Integer)
This allows you to add categories like this:
to add a category with an ID of 4 to the list.
Inside the BlogEntry class you can use this list to update the database. You could use the Split method I mentioned earlier, or you can fire a store procedure to bind each BlogEntry to a category. If you take that route, here's what you should do:
1. Save the BlogEntry and return its ID
2. Fire a Delete procedure that deletes all junction records from the BlogEntryCategory table, based on the ID of the BlogEntry from 1)
3. For each item in your List(Of Integer) fire a stored procedure that receives the BlogEntryId and the CategoryId to insert the junction record.
In the front end, in the Save button's Click handler for the BlogEntry, you should do something like this:
1. Get a BlogEntry object using BlogManager.GetBlogEntry(id)
2. Clear the (new) list of Categories:
3. For each selected category in a ListBox, add the selected ID to the Categories list.
4. Save the BlogEntry.
Does this put you on the right track?
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results
and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post