Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Implementing Two-Way Control Binding for Web Forms : Page 4

ASP.NET's native data binding provides only one-way data binding. With a little bit of effort, it's possible to extend the native functionality and provide flexible two-way data binding and a few other simple enhancements that drastically reduce the amount of code you have to write for binding data to controls.


advertisement
Adding Controls to the Form
The first step is to add the wwWebDataControls.dll to the Toolbar by following these steps:

  1. Select the Toolbox.
  2. Right-click and select Add New Tab.
  3. Type the name for this tab (e.g., West Wind Web Controls).
  4. Select the new tab.
  5. Right-click again and select Add/Remove Items.
  6. Browse for the installation directory for the samples and select the data binding/wwWebDataControls/bin/Debug/wwWebDataControls.dll.
  7. Later, you'll probably want to install this to the GAC. For now, it's handy to use the debug version so you can change the controls.
  8. Drag and drop the controls onto the form.
The controls use a default script tag prefix of ww, which is registered against the DLL. Here's the script code for the header:

<%@ Register TagPrefix="ww" Namespace="Westwind.Web.Data" Assembly="wwWebDataControls"%>

And for a control:

<ww:wwwebtextbox id="txtPrice" runat="server" size="20" BindingSourceObject="Inventory.DataRow" BindingSourceProperty="Price" UserFieldName="Price" DisplayFormat="{0:c}"></ww:wwwebtextbox>

If you use the toolbar, you won't have to do any of this manually. What's nice about this form is that other than the property assignments that are made in the property sheet (Figure 4), there's no code involved in the data binding. It's quick and easy to create the data bindings in this fashion.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date