将值分配给控制器中的绑定属性

时间:2018-12-16 17:38:33

标签: c# asp.net .net asp.net-mvc

我有创建控制器,在其中创建数据库条目

这是代码

summary(iris_kmeans)

但是对于属性[HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Create( [Bind("Title", "Date", "WorkTime", "Quantity", "ServiceId", "Price", "ProjectId", "WorkTimeTo", "CreatingDate", "WorkDoneFrom", "WorkDoneTo", "BreakFrom", "BreakTo")] Proposals proposal) { if (ModelState.IsValid) { _context.Proposals.Add(proposal); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Name",proposal.ServiceId); ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Name", proposal.ProjectId); return View(proposal); } ,我需要设置DateTime.now的值。如何将其正确应用于财产?

0 个答案:

没有答案