asp.net – 下载列表asp mvc
发布时间:2020-09-18 16:44:49 所属栏目:asp.Net 来源:互联网
导读:我想为我的模型类的一些属性生成一个下拉列表.我正在开发一个mvc .net应用程序,我正在使用razor引擎进行查看.这是我的班级: public class present{ public DateTime jour { get; set; } public int entree_mat_h { get; set; } public int entree_
我想为我的模型类的一些属性生成一个下拉列表.我正在开发一个mvc .net应用程序,我正在使用razor引擎进行查看.这是我的班级: public class present { public DateTime jour { get; set; } public int entree_mat_h { get; set; } public int entree_mid_h { get; set; } public int sortie_mat_h { get; set; } public int sortie_mid_h { get; set; } public int entree_mat_m { get; set; } public int entree_mid_m { get; set; } public int sortie_mat_m { get; set; } public int sortie_mid_m { get; set; } public string mac { get; set; } public string ip { get; set; } } 例如,我想显示一个下拉列表,其中每个属性为0到60,这是一个整数. 解决方法在您的视图中声明可能值的列表,在您的情况下从0到60@{ var values = new SelectList(Enumerable.Range(0,60)); } 然后,您可以在DropDownListFor帮助器中使用它 @Html.DropDownListFor(m => m.entree_mat_h,values) @Html.DropDownListFor(m => m.entree_mid_h,values) .... (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 保存后显示相同的页面
- asp.net – 为什么当试图保存更改时,GridView行“null”的D
- asp.net-mvc-3 – 将数组传递给RouteValues,并将其渲染为粘
- .NET牛人应该知道些什么,我的回答
- asp.net-mvc-2 – 带有数组/列表的ASP.NET MVC 2模型
- asp.net-mvc – 如何通过URL传递日期,为我的Action读取MVC?
- asp.net-mvc – 使用Asp.net MVC 4中的OutputCacheAttribut
- IIS和ASP.Net Web开发服务器之间的行为差异?
- asp.net-mvc – 隐藏日期时间的ASP.NET MVC格式
- asp.net – 在我的网站中添加HttpModule时出现“500内部服务
推荐文章
站长推荐
- asp.net-mvc-3 – 实体框架乐观并发异常未发生
- asp.net – 避免在web.config中提供服务器连接字
- asp.net-mvc – 未在ELMAH中记录的错误
- asp.net-mvc – 如何在多个Asp.net MVC应用程序中
- 实体框架 – 使用EF和WebAPI,如何返回一个ViewMo
- asp.net – 如何使用resxresourcewriter写入所有
- .net – asp:GridView文本框始终返回空值
- asp.net-mvc – 神秘的ASP.NET MVC Action高延迟
- asp.net – 为什么HttpContext.Current.User.Ide
- 认证 – WebApi ActionFilterAttribute,HttpActi
热点阅读