计算机专业外文翻译---用自定义控件简化aspnet20中的数据绑定-jsp程序(编辑修改稿)内容摘要:

ol manages the process of binding the specified data values to the specified control property, as well as unbinding the value back into the underlying data item. This is true twoway data binding. The Problem with Stock Data Binding 9 natively provides you with reasonable support for inbound data binding. Its native data binding expressions use % Eval(FieldName) % or direct page level expressions like % % to bind data to control properties. You call the DataBind method on the page or any control of the page to initiate the data binding process. This works well for inbound binding. However, unbinding and getting the data back into the underlying data fields or properties is not as readily available. introduces the GridView, FormView, and DetailsView controls, which let you use % Bind(FieldName) % syntax that provides twoway data binding. Unfortunately, these controls are closely tied to an underlying data source control, which must be IEnumerablebased. So binding to an individual entity object, for example, is not supported. Perhaps the most serious problem with the native unbinding mechanisms is the way that unbinding errors are handled. If there39。 s a problem with the formatting of an input fieldsay a numeric field that contains an alpha character or a DateTime value that sets a month of 22you get a pagelevel exception when you try to save the value. While you can trap the exception in pagelevel error handling, you can39。 t summarize this information because the first exception will stop the unbinding process. If you have two or three errors on the page, it will take multiple post backs to handle these errors, which is very unattractive from a UI perspective (though you could use validators to prevent, rather than handle, the problem). Introducing a TwoWay Data Binding Control I created the wwDataBinder control to manage simple data binding in a more flexible (and I hope more logical) way. The control provides a number of handy features and capabilities: Support for deterministic twoway data binding Binding single object or data values to a control property Unbinding control properties to object or data values Handling data conversion from text to typed data Managing any binding errors in a BindingErrors collection 10 Support for custom validation events Checking for required values in input Displaying error icons next to controls Showing message summary with links to controls Adding binding errors programmatically To use the control, you simply drop it into an page. The control acts as an extender control for any existing controls on the form, and it adds a DataBindingItem property to the extended control in the Visual Studio174。 2020 Properties editor (as shown in Figure 1). Figure 1 Extending Controls with Data Binding Functionality (Click the image for a larger view) The control sits on the form as a nondescript grey container (you can see this at the bottom of Figure 1), which isn39。 t rendered at run time. It39。 s displayed on the form merely so you can set properties on the wwDataBinder control itself. As an extender control, wwDataBinder contains a collection of DataBindingItems that hold the configuration values for each of the extended controls. The collection of items is maintained in the HTML markup and the control looks like this: ww:wwDataBinder ID=DataBinder runat=server OnValidateControl=DataBinder_ValidateControl DataBindingItems ww:wwDataBindingItem runat=server 11 ControlId=txtProductName BindingSource= BindingSourceMember=ProductName IsRequired=True ErrorMessageLocation=RedTextAndIconBelow /ww:wwDataBindingItem ... more DataBindingItems /DataBindingItems /ww:wwDataBinder The collection establishes the individual bindings that are applied by the DataBinder. While wwDataBinder extends existing controls, nothing is actually extended until you explicitly set properties on the DataBindingItem extender property of any given control。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。