asp.net-mvc-2 – 如何在ASP.NET MVC2中枚举formcollection
发布时间:2020-12-16 04:35:55 所属栏目:asp.Net 来源:网络整理
导读:我之前使用的是 How can a formcollection be enumerated in ASP.NET MVC?的实现,但现在我在VS2010和MVC2上抱怨: Error 1 Cannot implicitly convert type 'System.Web.Mvc.IValueProvider' to 'System.Collections.Generic.IDictionary'. An explicit conv
我之前使用的是
How can a formcollection be enumerated in ASP.NET MVC?的实现,但现在我在VS2010和MVC2上抱怨:
Error 1 Cannot implicitly convert type 'System.Web.Mvc.IValueProvider' to 'System.Collections.Generic.IDictionary'. An explicit conversion exists (are you missing a cast?) C:~ProjectMVCControllersTheController.cs line ProjectMVC 代码是…… IDictionary<string,ValueProviderResult> tmpCollection = collection.ToValueProvider(); for (int j = 1; j <= noprops; j++) { string shopNmTmp = (from t in tmpCollection where t.Key.StartsWith(j + ".discount.sname." + j) select t.Value.AttemptedValue).First(); string shopCdTmp = (from t in tmpCollection where t.Key.StartsWith(j + ".discount.sref." + j) select t.Value.AttemptedValue).First(); ... 当我不看时,有什么改变;这编译,工作和运行,在MVC1中没有问题;但不会在2中编译. 谢谢 更新 我通过使用以下技术来解决这个问题: Dictionary<string,string> tmpCollection = collection.AllKeys.ToDictionary(k => k,v => collection[v]); 代替. 但是我仍然对它为什么在版本之间发生变化感兴趣. 解决方法
我通过使用以下技术来解决这个问题:
Dictionary<string,string> tmpCollection = collection. AllKeys.ToDictionary(k => k,v => collection[v]); 收集后添加了Linebreak.用于格式化 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 收藏的asp.net文件上传类源码
- asp.net-mvc – ASP.NET MVC将表单值传递给action方法
- ASP.NET linkbutton两次提高onBeforeUnload事件
- asp.net – 企业库4 dataconfiguration标记
- asp.net-core – Namespace .AspNetCore.Hosting vs .Exten
- asp.net – 在usercontrols之间共享数据
- [ASP.Net]用RssToolKit2.0解析RSS,制作RSS阅读器
- asp.net-mvc – 如何删除MVC网站中的所有当前域名Cookie?
- asp.net-mvc – IdentityServer MVC令牌过期
- asp.net-mvc – 在使用Asp.Net MVC ActionLink,RedirectToA
推荐文章
站长推荐
- asp.net – 在脚本标签src属性中使用波浪号
- asp.net – 如何处理@RenderBody()?
- asp.net-mvc – ASP.NET MVC 6中的文件IO Close(
- asp.net-mvc – 在MVC5中呈现Razor的部分视图
- asp.net – FormView无法显示
- 基于asp.net下使用jquery实现ajax的解决方法
- 如何从ASP.Net和C#中的数据库中获取和显示图像
- 奇怪的#_ = _出现在response.redirect ASP.NET之
- 每个“HttpRequest”在ASP.NET中都有自己的线程吗
- asp.net-web-api – ASP.NET核心Web API:为什么
热点阅读