在asp.net中为mvc2创建视图时出现问题 [英] Problem in create view for mvc2 in asp.net

查看:60
本文介绍了在asp.net中为mvc2创建视图时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我第一次在mvc中工作,我陷入了创建视图的麻烦.

我有两节课.一个是具有字段字符串名称,IList相阶段的配置文件.

hi guys,

i m working in mvc first time and i have got stuck in create view.

i have two classes. one is profile having fields string name,IList phase phases.

public class Profile
   {
       /// <summary>
       /// Private variables and virtual get set properties
       /// </summary>

       private string name;
       private IList<ProfilePhase> profilePhases;

       public virtual string Name
       {
           get
           {
               return name;
           }
           set
           {
               name = value;
           }
       }

       public virtual IList<Phase> Phases
       {
           get
           {
               return profilePhases;
           }
           set
           {
               profilePhases = value;
           }
       }
}




第二个是具有类int id和字符串名称的阶段类.




and second is phase class having fields int id and string name.

public class Phase
    {
        [HiddenInput(DisplayValue = false)]
        public virtual int PhaseId
        {
            get;
            set;
        }
       [DisplayName("Phase Name")]
        public virtual string Name
        {
            get;
            set;
        }
    }




现在,当我为配置文件class.create创建一个视图时,它将显示配置文件中包含的所有文本框(阶段列表除外).但是我还需要在创建视图中显示(阶段列表)文本框.

我正在执行此操作,但无法获得正确的视图.

foreach(Model.phases中的var phase)

但它没有提供阶段类的字段,也没有在配置文件创建视图中为阶段创建文本框.


在此先感谢




Now when i create a create view for the profile class.it shows all the textboxes contain in profile except the list of phases. But i need to show (list of phases) textboxes also in create view.

I m doing this but don''t get the correct view.

foreach(var phase in Model.phases)

but it doesn''t give the field of the phase class and not creating the textboxes for the phase in profile create view.


Thanks In Advance

推荐答案

您的控制器类是什么?如何分配控制器类.
What is your controller class? How you are assigning controller class.


这篇关于在asp.net中为mvc2创建视图时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆