I have these two methods below. One returns a list of manufacturers based on the handset ID and the other returns a list of Handsets based on the Handset ID (relationship via handset ID). How can I combine them to return one select list with the combined manufacturer handset value?
(Bit new to MVC)
SelectList GetManufacturers()
{
var manufacturers = ((DataPage<Manufacturer>)ViewData["Manufacturers"]).Records;
return new SelectList(manufacturers, "ID", "Name", ViewData.Model.HandsetID != null ? ViewData.Model.HandsetID : -1);
}
SelectList GetHandsets()
{
var list = ((DataPage<Handset>)ViewData["Handsets"]).Records;
return new SelectList(list, "ID", "Name", ViewData.Model.HandsetID != null ? ViewData.Model.HandsetID : -1);
}
Help greatly appreciated,
Kind regards
The following code should work. It performs an inner join on your two lists, and then concatenates the manufacturer name and handset names of each record, with a space in between.