This walkthrough shows you how to WebCombo to client-binding using AdoDataService mode.
During this walkthrough, you will learn how to do the following:
- Create and use AdoDataService mode.
- Configure WebCombo to client-binding using AdoDataService mode
Prerequisites
In order to complete this walkthrough, you will need the following:
- ADO.NET Entity Data Model.
- Visual Studio 2008/2010 Application.
Step-By-Step Instructions
To configure client binding using WebService mode
- Launch Visual Studio.NET 2010.
- Click on File menu, then select New and click Web Site.
- Select ASP.NET Web Site in the Template box.
- Named the Web Site and click OK.
- In the Solution Explorer, right-click on App_Data and select Add Existing Item.
- Browse and add NorthWind.mdf in C:\Program Files\Intersoft Solutions\Data (Default installation folder).
- In the Solution Explorer, right-click on App_Code and select Add New Item.
- 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.
- On the next screen, choose Customers to include in your database model. Click Finish.
- In the Solution Explorer, right-click on the WebProject and select Add New Item.
- Create a new WCF Data Service and named it NorthwindDataService.svc.
- Modify the NorthwindDataService.svc.cs to accept Customers and have full access.
C# Copy Code using System; using System.Data.Services; using System.Collections.Generic; using System.Linq; using System.ServiceModel.Web; using NorthwindDataModel; [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("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); config.UseVerboseErrors = true; } }
- In the Solution Explorer, right-click on the project and select Add New Item.
- Select Web Form in the Templates box and named it as Walkthrough.aspx.
- Drag WebCombo instance from Toolbox to WebForm.
- Set the properties based on the table and code below.
Property Value BindingOperationMode ClientBinding DataSourceType AdoDataService ServiceUrl NorthwindDataService.svc
HTML Copy Code <ISWebCombo:WebCombo ID="wcCustomers" runat="server" Height="20px" UseDefaultStyle="True" Width="150px" ViewStateStorage="None" DataTextField="ContactName" DataValueField="CustomerID" DataMember="Customers" BindingOperationMode="ClientBinding"> <FlyPostBackSettings PostHiddenFields="true" PostInputControls="true" /> <ClientBindingSettings DataSourceType="AdoDataService" ServiceUrl="NorthwindDataService.svc" /> </ISWebCombo:WebCombo>
- Run the project and the WebCombo should look like following.