Using the DomainDataSource Control The great part about RIA services is that you don't need to write much backend code to get a number of cool features ? all that you need to do is adding some controls to the XAML and configuring them. The main such control is the DomainDataSource control that you add to the page. First, remove all the code that was added to the MainPage.xaml.cs file above. Next, in the toolbox of VS/VWD add a new item and select the DomainDataSource control, and then once, it appears in the toolbox, drag and drop it above the DataGrid control. Also add the following namespaces to the top of the page:
xmlns:ds="clr-namespace:SLRIA.Web"xmlns:riaData="clr-namespace:System.Windows.Data;assembly=System.Windows.Ria.Controls"
Change the DomainDataSource control you added earlier to look like this:
And add the ItemSource attribute to the DataGrid to point to this data source:
Running the page now will display same data as before, but without any backend code. The DomainDataSource control also allows you to add filters, sorting and paging capabilities into it. For this, first add a new TextBox control named 'txtNameFilter' before the grid and then add the following inside DomainDataSource:
You can also add a DataPager control below the grid to add paging capabilities like this:
Running the application now will allow you to see the data from different tables in the grid. The records shown are only 10 per page and you can use the pager at the bottom of the grid to navigate the records.
Finally, you can even filter the records by typing in a few characters of the name in the text box and as you type, the rows will be automatically filtered. As you can see, the RIA Services allows you to perform a large number of business / data related work very easily. Next month, we'll take a look at how you can add, modify and delete data from this table as easily as this.
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.