Create.cshtml
@Html.DropDownList("KategoriId",null,htmlAttributes: new { @class="form-control"})
MakaleController.cs
public ActionResult Create()
{
ViewBag.KategoriId = new SelectList(db.Kategoris, "KategoriId", "KategoriAdi");
return View();
}
but it's say When I make a post request,
The ViewData element with the 'KategoriId' key is of type 'System.Int32', but of type 'IEnumerable '.
How to fix this error, I tried many ways but it did not happen. He says that the value is generally null.
Kategori.cs (!! NOT KATEGORIS, i create with code first)
[Table("Kategori")]
public partial class Kategori
{
public int KategoriId { get; set; }
[StringLength(50)]
public string KategoriAdi { get; set; }
public virtual Makale Makale { get; set; }
}