Home > Articles > Programming > Windows Programming

LightSwitch: Implementing Custom Paging with Search Screens That Use Custom Controls

  • Print
  • + Share This
Alessandro Del Sole describes how to use custom paging in Visual Studio LightSwitch to supply functionality while simplifying your coding. In this example, he walks you through replacing the built-in Data Grid with custom controls and a page navigation mechanism for faster and more efficient data access.
From the author of

One great benefit of Visual Studio LightSwitch is that search screens and editable grid screens implement a paging mechanism that optimizes the loading of large collections of entities and that allows browsing records in the collection easily. Figure 1 shows an example of built-in paging, which is generated automatically and without writing a single line of code.

By default, LightSwitch returns 45 data items per page, but you can change this number (or completely disable paging) by selecting the data collection in the screen designer and then opening the Properties window. As you may know, LightSwitch extensibility allows replacing built-in controls with custom controls that often extend functionalities of the predefined applications' shell. For instance, you can replace the built-in Data Grid with a more sophisticated version.

Using custom controls also removes the built-in search box and paging mechanisms, which could be a potential limitation, but you can still implement your paging mechanism with a limited effort.

In this article, I'll show you how to replace the default Data Grid control with the RadGridView control from Telerik, a well-known partner of Microsoft. A trial version is available for download.

Creating the Sample Project

Once you've downloaded and installed the Silverlight controls from Telerik, which include the RadGridView control, create a new LightSwitch application. To make things easier, the Northwind sample database is used as an external data source.

Follow these steps:

  1. In the LightSwitch designer, click Attach to External Data Source.
  2. Select the Database option.
  3. Establish a connection to the Northwind database.
  4. Select the Customers table.
  5. Once the table is imported into a new entity in LightSwitch, add a new screen of type Editable Grid based on the Customers table.
  • + Share This
  • 🔖 Save To Your Account