你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!

关于DXperience 13.1 Combobox问题

已邀请:

ASP.NET MVC3 View中 引入Combobox 后部门 "ID" 无法传入Controller中 View代码:

                @Html.DevExpress().ComboBox(settings =>
                 {
                     settings.Name = "DeptID";
                     settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
                     settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                     settings.Properties.TextField = "Name";
                     settings.Properties.ValueField = "ID";
                 }).BindList(ViewBag.Departments).GetHtml()

Controller代码:

                           public ActionResult Add(User user)
                            {
                               userService.Add(user);  //断点 user.DeptID = 0 ?
                               return View("Index");
                            }

Model:

   
   [Table("Department")]
    public class Department
    {
        [Key]
        public int ID { get; set; }
        [Required]
        public string Name { get; set; }
    }

    [Table("User")]
    public class User
    {
        [Key]
        public string UserID { get; set; }
        [Required] 
        public string UserName { get; set; }
        public string Password { get; set; }
        [Required] 
        public string UserRight { get; set; }
        [Required]
        public int DeptID { get; set; }
        [ForeignKey("DeptID")] 
        public Department Department { get; set; }
    }

要回复问题请先登录注册

微信