Marius Vasile

Marius Vasile

  • 599
  • 1.9k
  • 142.9k

asp.net core selectlist to show multiple text values

Jan 23 2021 4:21 PM
I have a table with 3 entries in addition to the Id. I want a select list to show all entries in a row, for better identification of the data. Right now select only show me either the value (Id) or one text(one field) from table
 
ex.
 
  1. <select id="Location" class="form-control border-warning" asp-items="Model.Locations">  
  2.                     <option value="">--Select Asset Location--</option>  
  3.                 </select>  
In the table I have the following fields Id, Location, City, Country
 
  1. Locations = await _context.WOAssetLocations.Where(s => s.OrgID == orgid)  
  2.                                       .Select(s => new SelectListItem  
  3.                                       {  
  4.                                           Value = s.WOALId.ToString(),  
  5.                                           Text = s.AssetLocation  
  6.                                       }).ToListAsync();  
get me only one field, depending on my choice, either Location, City or Country. This is good but the select I want to show in a row all values coresponding to Id 

Answers (4)