Marius Vasile

Marius Vasile

  • 590
  • 1.9k
  • 149k

ASP.NET Core EF set @html as input source

May 17 2020 10:51 AM
I don't understand why the table adds only one value and it doesn't add the second one. For the HazardClass is working fine but for HazardDetails is not
 
Update. It seems that the problem I have is with:
 
  1. <div class="form-control">  
  2.                 @Html.DisplayFor(model => model.HazardClass.IdHC)  
  3.             </div>  
which also should be source for input
 
  1. var emptyHaz = new HazardDetail();  
  2.   
  3.             if (await TryUpdateModelAsync<HazardDetail>(emptyHaz, "hazardDetail", s => s.IdHC, s => s.HazDetail))  
  4.             {  
  5.                 _context.HazardDetails.Add(emptyHaz);  
  6.                 await _context.SaveChangesAsync();  
  7.                 return RedirectToPage("./Index");  
  8.             }  
So, the question is, how do I get the @html..... to be input  for IdHC?
 

Answers (5)