在View MVC 4中的单选按钮列表的模型中设置枚举选择列表

时间:2014-04-19 14:51:59

标签: c# asp.net-mvc-4 enums

  

是否可以在模型控制器中创建带枚举的多个选择列表,并在View控制器中使用>这些枚举选择列表作为单选按钮列表?   我已经在网上看了一些能帮助我理解我是什么的东西,并试图在没有任何真正成功的情况下做到这一点。我发现各种各样的零碎有点>相关,但没有涉及在模型>控制器中设置枚举选择列表。
  如果您可以帮我解决这个问题,或者知道与此主题相关的资源,那么,非常感谢您的帮助和帮助。

     

以下是我现在编码模型控制器的方法:

 namespace CIOS.Models
{
    /**
    * Class Name: 
    * Class Purpose: 
    * 
    * Date Created: 
    * Last Modified: 
    * @author 
    */
    [Table("Evaluation")]
    public class Evaluation
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int evaluationId { get; set; }
        public int studentId { get; set; }
        public int opportunityId { get; set; }

        public string attitude { get; set; }

        public string abilityToLearn { get; set; }

        public string judgement { get; set; }

        public string dependability { get; set; }

        public string initiative { get; set; }

        public string relationshipWithOthers { get; set; }

        public string maturity { get; set; }

        public string qualityOfWork { get; set; }

        public string attendance { get; set; }

        public string punctuality { get; set; }

        public string outstandingPersonalQualities { get; set; }
        public string needToImprove { get; set; }
        public Nullable<bool> discussedWithStudent { get; set; }

        public virtual Opportunity Opportunity { get; set; }
        public virtual Student Student { get; set; }

        // Lists for the evaluation category options for the radiobuttonList
        public List<SelectListItem> Attitude { get; set; }
        public List<SelectListItem> AbilityToLearn { get; set; }
        public List<SelectListItem> Judgement { get; set; }
        public List<SelectListItem> Dependability { get; set; }
        public List<SelectListItem> Initiative { get; set; }
        public List<SelectListItem> Relations { get; set; }
        public List<SelectListItem> Maturity { get; set; }
        public List<SelectListItem> Quality { get; set; }
        public List<SelectListItem> Quantity { get; set; }    
    }

    // Enum list values for radio button that are to be displayed in view.
    public enum Attitude 
    {
        Outstanding in enthusiasm,
        Very interested and industrious,
        Average in diligence and interest,
        Somewhat indifferent,
        Definitely not interested
    }
    public enum AbilityToLearn 
    {
        Learned work exceptionally well,
        Learned work readily,
        Average in understanding of work,
        Rather slow in learning,
        Very slow to learn
    }
    public enum Judgement 
    {
        Exceptionally mature in judgment,
        Above average in making decisions,
        Usually makes the right decision,
        Often uses poor judgment,
        Consistently uses bad judgment
    }
    public enum Dependability
    {
        Completely dependable,
        Above average in dependability,
        Usually dependable,
        Sometimes neglectful or careless,
        Unreliable
    }
    public enum Initiative 
    {
        Proceeds well on his/her own,
        Goes ahead independently at times,
        Does all assigned work,
        Must be pushed frequently
    }
    public enum Relations 
   {
        Exceptionally well accepted,
        Works well with others,
        Gets along satisfactorily,
        Has difficulty working with others,
        Works very poorly with others
    }
    public enum Maturity 
    {
        Quite poised & confident,
        Has good self-assurance,
        Average maturity and poise,
        Seldom shows maturity,
        Timid
    }
    public enum Quality
    {
        Excellent,
        Very good,
        Average,
        Below average,
        Very poor
    }
    public enum Quantity 
    {
        Unusually high output,
        More than average,
        Normal amount,
        Below average,
        Low output--slow
    }
}

如果这已经得到了解答,那么请向我提供我能够找到它的地方。我看过很多网站,他们开始一起跑。如果是这种情况,我会提前道歉 如果有解决方案,请为我提供该过程的解释或说明。

再次感谢。

0 个答案:

没有答案