Dynamic view of anonymous type missing member issue - MVC3

前端 未结 6 2015
春和景丽
春和景丽 2021-02-06 17:50

I have an MVC3 site that I\'ve setup for testing another site - most of it has been quick and dirty, and so I\'ve not gone to town creating model and view model types for all th

6条回答
  •  离开以前
    2021-02-06 18:32

    If you're just going for pure quick'n'dirty, you can always use Tuples in situations like this.

    ViewBag.SomeData = Enumerable.Range(1,10).Select(i=> new Tuple(i);
    

    -

    @foreach(dynamic item in ViewBag.SomeData)
    {
        @:Number: @item.Item1
    }
    

提交回复
热议问题