Binding Objects to Client-Side Controls.

This article is a continuation of Part 1 : Returning objects from a web service.

Windows form controls can easily be bound to either a single object or a collection of objects returned to the client by a web service.
This article demonstrates how to bind a object array to a DataGridView.The code for this demo can be downloaded here.

Steps.

  • Create a New Window Application in VS2005.
  • Add a reference to the web service created in Part 1.
  • Add a DataGridView to Form1.
  • Using Smart Tags add a datasource to the DataGridView (Smart Tags can be invoked by clicking the small black triangle on the top of your DatagridView Control.
    Click Other Data Sources > Project Data Sources > Localhost > Account
  • bindingobjects1.png

    This creates a BindingSource object named accountBindingSource.

  • In the Form1_Load method add the following code.
  • myService = new localhost.Service();

    accountBindingSource.DataSource=myService.getBankAccounts();

  • Run you Program and the below is displayed
  • objectbinding1.png

    .NET has bound the object Array returned from the web service to the DataGridView.

    It really is as simple as that!

    Happy Coding!

    technorati tags ,

    One Response to “Binding Objects to Client-Side Controls.”

    1. xHydra Tech Zones » Returning Objects From a .NET Web Service. .Net,SQL Server,Tech news, reviews, articles Says:

      […] and Views      « Installing WAMP on Windows XP Home Edition. Binding Objects to Client-Side Controls. […]

    Leave a Reply