Checkboxes to indicate inclusion in a list?
I have two tables, called Machine
and Type
. Since they have a many-many relationship, I have a MachineType
resolution table in my DB. No problem.
The end user needs to be able to manage these - create new types and assign them to machines. I have an XtraGridView
that I am using to display the Machine
as master and Type
as detail.
Initially I used a Lookup
to add Type
dropdowns to the MachineType
detail view. But that creates duplicates and is not the best way to display this information. I'd like a series of checkboxes (one for each Type
options available) so the user can click the appropriate ones for each machine, thus avoiding duplicates. Upon saving, the appropriate MachineType
rows can be generated.
I was 开发者_如何学Cgoing to just code this manually but if there's some kind of binary collection mapping in either DevExpress or the .net framework I can use, I'd prefer that than to reinvent the wheel.
Cheers
EDIT: This is what I mean. From this thread. However, they store it as a collection (a string delineated by commas) and not a series of DB rows.
Are you interested in just returning the values to bind to as a linq query?
from m in Machine
from t in Type
select new {m,t}
This will give you a cross join for each of the pairings on save you can just check to see if the MachineType table has the pairing already
from mt in MachineType
where mt.MachineId == <machine from list>
&& mt.TypeId == <type from list>
if you want to pass the query lists you can send a list of pairings you can send a dictionary and loop through it or use the Contains()
function if dictionaries support that.
精彩评论