Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 如何跨回发维护基本类型集合中的项类型?_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 如何跨回发维护基本类型集合中的项类型?

Asp.net mvc 3 如何跨回发维护基本类型集合中的项类型?,asp.net-mvc-3,Asp.net Mvc 3,我有一个基类、一组子类和一个集合容器,用于使用局部视图动态创建和填充控件 // base class public class SQControl { [Key] public int ID { get; set; } public string Type { get; set; } public string Question { get; set; } public string Previous { get; set; } public vi

我有一个基类、一组子类和一个集合容器,用于使用局部视图动态创建和填充控件

// base class
public class SQControl
{
    [Key]
    public int ID { get; set; }
    public string Type { get; set; }
    public string Question { get; set; }
    public string Previous { get; set; }
    public virtual string Current { get; set; }
}

// subclass
public class SQTextBox : SQControl
{
    public SQTextBox()
    {
        this.Type = typeof(SQTextBox).Name;
    }
}

//subclass
public class SQDropDown : SQControl
{
    public SQDropDown()
    {
        this.Type = typeof(SQDropDown).Name;
    }

    [UIHint("DropDown")]
    public override string Current { get; set; }
} 

// collection container used as the Model for a view
public class SQControlsCollection
{
    public List<SQControl> Collection { get; set; }
    public SQControlsCollection()
    {
        Collection = new List<SQControl>();
    }

}
所以我的问题是,有没有更好的方法在回发之间维护基类型集合中的项类型?我知道在MVC中,每个模型都有一个类型化视图是一种惯例,但我希望能够使用可重用的局部视图基于XML文档动态构建视图。

签出
// base class
public class SQControl
{
    [Key]
    public int ID { get; set; }
    public string Type { get; set; }
    public string Question { get; set; }
    public string Previous { get; set; }
    public virtual string Current { get; set; }
}

// subclass
public class SQTextBox : SQControl
{
    public SQTextBox()
    {
        this.Type = typeof(SQTextBox).Name;
    }
}

//subclass
public class SQDropDown : SQControl
{
    public SQDropDown()
    {
        this.Type = typeof(SQDropDown).Name;
    }

    [UIHint("DropDown")]
    public override string Current { get; set; }
} 

// collection container used as the Model for a view
public class SQControlsCollection
{
    public List<SQControl> Collection { get; set; }
    public SQControlsCollection()
    {
        Collection = new List<SQControl>();
    }

}