08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

126<br />

CHAPTER 5 ■ <strong>ASP</strong>.<strong>NET</strong> WEB SERVICES<br />

You can see here how the uses the TypeName parameter to set<br />

up the web service binding <strong>and</strong> the SelectMethod to configure the method that it will call<br />

on this service. As we are running a Select (i.e., a read-only query) from this web service,<br />

the child is present. This contains an node, which<br />

configures the name, form field, <strong>and</strong> default value to call on this web service.<br />

Now that we have the binding set up, we can easily place a control to bind to. A great<br />

control for this is the GridView control, which provides advanced functionality such as<br />

paging <strong>and</strong> sorting. To use one, simply drag the GridView control from the Data tab on<br />

the Visual Studio Toolbox to the design surface. The adorner will open, <strong>and</strong> you can use<br />

this to configure the data source. Select the ObjectDataSource control that you configured<br />

earlier <strong>and</strong> the grid will be bound to it (see Figure 5-18).<br />

Figure 5-18. Data binding a grid to a web service via an ObjectDataSource<br />

If you now execute the application, the grid will bind to the web service <strong>and</strong> render<br />

the data for the default parameter. You can also type new parameters into the text box<br />

<strong>and</strong> click the button, <strong>and</strong> they will be fetched <strong>and</strong> rendered for you. And this was all<br />

achieved without writing a single line of code on the client!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!