简体   繁体   English

ASP.NET MVC2 形式到 object 数据绑定实用程序

[英]ASP.NET MVC2 form to object data binding utility

I run application business logic in CRM 2011 for now I need to create a web page to allow the public users to create orders etc. from ASP.NET application and save them in CRM.我现在在 CRM 2011 中运行应用程序业务逻辑,我需要创建一个 web 页面,以允许公共用户从 ASP.NET 应用程序创建订单等并将它们保存在 CRM 中。

I'm playing with CRM web services, I even created a couple of forms by the way I'm looking for data binding mechanisms or tools to map the submitted form values into appropriate CRM Entity eg Order.我正在玩 CRM web 服务,我什至创建了几个 forms,顺便说一下我正在寻找 map 的数据绑定机制或工具,例如将提交的表单值放入适当的 CRM 中。

How bind forms to CRM entities?如何将 forms 绑定到 CRM 实体?

Sultan苏丹

If you've just started using MVC then perhaps you are not familiar with model binding.如果您刚刚开始使用 MVC,那么您可能不熟悉 model 绑定。 Basically MVC will map the contents of a request ( post or get ) to a strongly typed object for you.基本上,MVC 会将 map 请求的内容( postget )发送给强类型的 object。 At it's simplest this is achieved (automatically and 'behind the scenes' by matching the name / key of an item in a request to the name of a property on your object. Here's a quick video showing how model binding works (over just working with the form collection directly). And this article goes into the detail of enabling basic CRUD functionality for a given model. Reading this should give you a sense of working with models, having your views strongly typed so you can make the model binding work easily.在最简单的情况下,这是通过将请求中项目的名称/键与 object 上的属性名称匹配来实现的(自动和“在幕后”。这是一个快速视频,展示了 model 绑定的工作原理(仅使用直接表单集合)。 本文详细介绍了为给定的 model 启用基本 CRUD 功能的细节。阅读本文应该让您对使用模型有一种感觉,让您的视图具有强类型,因此您可以轻松地使 model 绑定工作。

I would also recommend you read up on validation with data annotations attributes .我还建议您阅读有关使用数据注释属性进行验证的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM