应该是没有安装sp1的缘故吧,我新建View或者Controller的时候,没有反应。
我可以用复制的方式,把照着默认生成的View新建一个View
但是我现在刚刚新建了一个Model
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace FirstMVC.Models
{
public class FirstModel
{
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 性别
/// </summary>
public bool Sex { get; set; }
}
}
怎样为这个Model新建对应的View呢?
public partial class ModelView : ViewPage<List<Models.FirstModel>>
{
}
这种方式,提示如下错误:
The model item passed into the dictionary is of type 'FirstMVC.Models.FirstModel' but this dictionary requires a model item of type 'System.Collections.Generic.List`1[FirstMVC.Models.FirstModel]'.
另外,怎样在ModelView.aspx中把Model的数据提取出来?
<%ViewData.Model.FirstModel %>不行吧。
本人初学MVC,请高手不吝赐教。
两个命名空间里有相同的类名导致的问题吧.
public partial class ModelView : FirstMVC.Models.FirstModel.ViewPage<List<Models.FirstModel>>
{
}
定义的时候带上命名空间试试!
装VS2010吧,什么都有了。