ASP.NET MVC - 动态下拉列表

时间:2015-07-16 14:08:04

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

我这里有一个复杂的问题。这是所需的界面:

enter image description here

当您点击Add grade时,会使用javascript添加select和input.text。这里的问题是如何将所有这些转移到控制器? 以下是使用的模型:

public class Student {

    public int Id { get; set; }

    [Required]
    [Display(Name = "First name")]
    public string FirstName { get; set; }

    [Required]
    [Display(Name = "Last name")]
    public string LastName { get; set; }

    [Required]
    [Display(Name = "Grades")]
    public virtual IList<Grade> Grades { get; set; }
}


public class Grade {

    public int Id { get; set; }
    public int ClassId { get; set }
    public int StudentId { get; set; }

    [Required]
    [Display(Name = "Class")]
    public virtual Class Class { get; set; }

    [Required]
    [Display(Name = "Value")]
    public string Value { get; set; }
}


public class Class {

    public int Id { get; set; }

    [Required]
    [Display(Name = "Name")]
    public string Name { get; set; }
}

有没有人遇到过这个?

1 个答案:

答案 0 :(得分:0)