Benmakhlouf Saad

Benmakhlouf Saad

  • 1.9k
  • 134
  • 8.5k

MVC : Display Value Insteadof The Id

Mar 31 2020 8:51 AM
Hi,
I want to Display Username instead of Userid but it should take the Userid Value
I have 2 tables : AspNetUsers and AspNetUserRoles 
  1. ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id""Id");  
  1. <div class="form-group">  
  2.                 <label asp-for="UserId" class="control-label"></label>  
  3.                 <select asp-for="UserId" class="form-control" asp-items="ViewBag.UserId"></select>  
  4. </div>  
 

Answers (2)