如何拥有动态数量的列表视图模型?

时间:2016-12-16 14:31:01

标签: asp.net asp.net-mvc entity-framework

几周前我有一个上一个问题,我现在明白了答案,但现在我想更进一步。

以下是我正在使用的模型:

public class Test {
    public string author {get;set;}
    public list<TestItem> testItems {get;set;}
}
public clas TestItem{
    public string question {get;set;}
    public string answer {get;set}
}

我在以前的项目中提出了类似这样的观点(包含4个项目的测试):

Test model = new Test()
{
    Test= new List<TestItem>()
    {
        new TestItem() { },
        new TestItem() { },
        new TestItem() { },
        new TestItem() { }
    }
};
return View(model)

我可以在我的控制器中的get方法中创建测试和SET数量的测试项目以进入该测试。但是,我想让我的用户确定测试可以持续多长时间,也许是3个问题,也许是33个问题。我如何确定客户端的testItem数量?

0 个答案:

没有答案