У меня проблема в ASP.NET MVC с проверкой DropDownList.У меня есть два действия «Создать».Они определены следующим образом:
public ActionResult Create()
{
var categoriasDownloads = from catDown in modelo.tbCategoriasDownloads
orderby catDown.TituloCategoriaDownload ascending
select catDown;
ViewData["CategoriasDownloads"] = new SelectList(categoriasDownloads, "IDCategoriaDownloads", "TituloCategoriaDownload");
var formatosArquivos = from formatosDown in modelo.tbFormatosArquivos
orderby formatosDown.NomeFormatoSigla
select formatosDown;
ViewData["FormatosArquivos"] = new SelectList(formatosArquivos, "IDFormatoArquivo", "NomeFormatoSigla");
return View();
}
и второе действие Создать:
[HttpPost]
public ActionResult Create(tbDownloads _novoDownload)
{
TryUpdateModel(modelo);
TryUpdateModel(modelo.tbDownloads);
if (ModelState.IsValid)
{
modelo.AddTotbDownloads(_novoDownload);
modelo.SaveChanges();
return RedirectToAction("Sucesso", "Mensagens");
}
return View(_novoDownload);
}
Проблема заключается в следующем: при попытке выполнить проверку проверка не происходит.Я использую аннотации данных для проверки, но у меня не получилось.
Что мне делать?
Спасибо