Step 3 of 3: Connecting the Web Service and Adding Stealth Paging

In the previous step you created a Web Service and added a data source to your project. In this step you'll continue by linking the Web Service to your application.

To set up your project, complete the following steps:

1.   Return to the MainPage.xaml file.

2.   In the Solution Explorer, right-click the project name and select Add Service Reference from the context menu.

3.   In the Add Service Reference dialog box click the Discover button. The DataWebService.asmx file will appear in the list of Services.

4.   In the Namespace text box, change the default value to "DataService" and click the OK button to save your settings and close the dialog box.

5.   Customize your grid by adding LoadedRowPresenter="peopleDataGrid_LoadedRowPresenter" to the <c1:C1DataGrid> tag so that it appears similar to the following:

<c1:C1DataGrid x:Name="peopleDataGrid" AutoGenerateColumns="True" CanUserAddRows="False" LoadedRowPresenter="peopleDataGrid_LoadedRowPresenter">

This markup adds an event handler – you'll add code for the event handler in the next steps.

6.   In the Solution Explorer, expand the MainPage.xaml node and double-click the MainPage.xaml.cs or MainPage.xaml.vb file to open it in the Code Editor.

7.   Add the following import statements at the top of the file:

      Visual Basic

      C#

8.   Add the following variables to the MainPage class:

      Visual Basic

      C#

9.   Add code to the MainPage constructor so it appears like the following:

      Visual Basic

      C#

10.  Add the LoadedRowPresenter event handler to your code under the MainPage constructor:

      Visual Basic

      C#

11.  Add the following code to retrieve data from the server:

      Visual Basic

      C#

12.  Run your application and observe that the grid appears bound to a data source:

 

 

13.  Run your application and observe that as you scroll through the grid more rows appear in the grid:

 

 

Also note that the text below the grid indicates the rows being added as you scroll.

 What You've Accomplished

Congratulations, you've completed this tutorial! In this tutorial you created a new Silverlight project, added a data source, and created a Web Service to bind the C1DataGrid control. You implemented stealth paging, so that when the grid is scrolled at run time, the grid pages through the grid instead, improving performance.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.