In the code below I would like for 'the data text field' to have both "FirstName" and "LastName" not only "FirstName" for the producers and actors. I am using this for a dropdownlist.
public async Task<IActionResult> Create()
{
var movieDropdownsData = await _service.GetNewMovieDropdownsValues();
ViewBag.Cinemas = new SelectList(movieDropdownsData.Cinemas, "Id", "Name");
ViewBag.Producers = new SelectList(movieDropdownsData.Producers, "Id", "FirstName");
ViewBag.Actors = new SelectList(movieDropdownsData.Actors, "Id", "FirstName");
return View();
}
From what I read I have to add and extra 'data text field' but I don't know how.
CodePudding user response:
I would suggest you modify your classes to have something like this - with proper names/format perhaps. Then just use that
public string FullName { get { return this.FirstName " " this.LastName;} }