As we near the release of version 2010.2 of DXperience, I’m going to work on bringing you some training material in the form of blog posts and videos to help you get started with using the new products and features that make up our Silverlight and WPF product lines.
First one in line is the new Data Grid Control for Silverlight. With all things grid related, the most important first step is of course, you guessed it, binding to data. A grid can be populated with data through different sources, including automatic data generated at runtime, static data, or database tables. In this tutorial we’ll take a look at how to bind the new DXGrid control for Silverlight to a local SQL Server 2008 R2 Express database using WCF RIA Services.
Note: This examples assumes the availability of a local SQL Server Express instance (“.\SQLEXPRESS”).
Video

Step-by-Step Tutorial
So let’s get started... the first step would be to create a new Silverlight Application Project and enable WCF RIA Services.

Next step would be to create a new Entity Data Model in the ASP.NET project that’s being used to host the Silverlight application.Select to generate the model from database, and from the desired database server, select the table that you’d like to use to populate the grid control. In this case, it’s the “Product” table from my sample database.

Make sure you re-build the solution before proceeding further. Create a Domain Service Class and add it to the ASP.NET project. You’ll be asked to select the data contexts and the entities to be used in this domain service.

Once the class has been created, switch to the Silverlight designer and add a new DevExpress GridControl to the application. Set the AutoPopulateColumns property to True so that columns are automatically created based on the available fields in the data source. Then switch to code view and use the following C# code to bind the grid to data:
...
using System.ServiceModel.DomainServices.Client;
using DXGridSL.Web;
...
private ProductContext _productContext = new ProductContext();
public MainPage() {
InitializeComponent();
LoadOperation<Products> loadOperation = _productContext.Load(_productContext.GetProductsQuery());
gridControl1.DataSource = loadOperation.Entities;
}
And that’s it! Run the Silverlight application and the grid is bound to the SQL Server database and populated with data.