Intersoft WebGrid Documentation
Walkthrough: Configuring client-binding using AdoDataService mode
See Also Send comments on this topic.

Glossary Item Box

This walkthrough shows you how to WebGrid to client-binding using AdoDataService mode.

During this walkthrough, you will learn how to do the following:

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Access to the Microsoft Access Northwind database.
  • Visual Studio 2008 Application.

 Step-By-Step Instructions

To configure client binding using AdoDataService mode

  1. Launch Visual Studio.NET 2008.
  2. Click on File menu, then select New and click Web Site.
  3. Select ASP.NET Web Site in the Template box and set Location to HTTP.
  4. Named the Web Site and click OK.
  5. In the Solution Explorer, right-click on App_Data and select Add Existing Item.
  6. Browse and add Northwind.mdf in C:\Program Files\Intersoft Solutions\WebUI Studio for ASP.NET\Data (Default installation folder).
  7. In the Solution Explorer, right-click on App_Code and select Add New Item.
  8. Create a new ADO.NET Entity Data Model and named it NorthwindDataModel.edmx. Pick generate the model from database, choose Northwind.mdf as the data source and named the entity as NorthwindEntities.



  9. On the next screen, choose Customers to include in your database model. Click Finish.
  10. In the Solution Explorer, right-click on the WebProject and select Add New Item.
  11. Create a new ADO.NET Data Service and named it NorthwindDataService.svc.
  12. Modify the NorthwindDataService.svc.cs to accept Customers and have full access.
    C# Copy Code
    using System;
    using System.Collections.Generic;
    using System.Data.Services;
    using System.Linq;
    using System.ServiceModel.Web;
    using System.Web;
    namespace WebApplicationWalkthrough2009
    {   
       [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]   
       public class NorthwindDataService : DataService<northwindentities>   
       {       
          // This method is called only once to initialize service-wide policies.       
          public static void InitializeService(IDataServiceConfiguration config)       
          {           
             // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.           
             // Examples:           
             // config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);           
             // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
             
             config.SetEntitySetAccessRule("*", EntitySetRights.All);         
             config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
             config.UseVerboseErrors = true;       
          }   
       }
    }
    

  13. In the Solution Explorer, right click on the project and select Add New Item.
  14. Select Web Form in the Templates box and named it as Walkthrough.aspx.
  15. Open Walkthrough.aspx in Source view and change the doctype from

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    Into the following
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>            
    
  16. Drag WebGrid instance from ToolBar to WebForm.
  17. Click the smart tag button on the upper right corner of WebGrid and then select WebGrid.NET Designer.
  18. Select Data Source (Advanced) from the left pane of Quick Start tab.
  19. On the specifies how WebGrid should perform data binding operation option, please select Client-side binding (Advanced).
  20. Select Connect to ADO.NET data service (Astoria) from Data source type option
  21. Set the Service Url to NorthwindDataService.svc.



  22. Click the Advanced tab and go to WebGrid - WebGrid1 > RootTable.
  23. Set DataKeyField to CustomerID and DataMember to Customers.
  24. Click the Advanced tab and go to WebGrid - WebGrid1 > RootTable > Columns.
  25. Click Add button from the right pane toolbar.
  26. Set Name, Caption, and DataMember to CustomerID.
  27. Repeat step number 26 and set the value of those properties to CompanyName; ContactName; ContactTitle; Address; City; Region; PostalCode; Country; Phone; and Fax.



  28. Run the project and the WebGrid should look like following.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.