The ViewData item that has the key 'GenderID' is of type 'System.Int32' but must be of type 'IEnumerable'

前端 未结 2 463
梦毁少年i
梦毁少年i 2021-01-24 22:18

The error occurs when i tried to Submit/Post the data... could someone please help i tried every post but they are not helping me. I am new to mvc... any help will be granted he

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 22:43

    It could be a problem between the "Gender":

    [Display(Name="Gender")]
    public int GenderID { get; set; }
    
    public IEnumerable Gender { get; set; }
    

    If I remember well, MVC attempts to map the fields automatically. Try renaming the (Name="Gender") in (Name="GenderID") or IEnumerable Gender in IEnumerable GenderEnumeration

提交回复
热议问题