Last week, I was working on a Silverlight LOB application. I came across a requirement for providing an ASP.NET GridView like behavior for the Silverlight DataGrid. I thought of writing an article and sharing my code with you all. In this article, we will see how to perform Insert, Update and Delete operations in the Silverlight DataGrid. We will first see the Update and Delete operations, and then explore Insert operations on the Silverlight DataGrid. I have used WCF Data Service in this article.
I have also used a SQL Server 2008 database and the Database name is ‘Company’ with a table ‘Customer’. The DDL statement is as below:CREATETABLE [dbo].[Customer](
[CustomerID] [int] NOTNULL,
[CustomerName] [varchar](50)NOTNULL,
[Address] [varchar](50)NOTNULL,
[City] [varchar](50)NOTNULL,
[State] [varchar](50)NOTNULL,
[Age] [int] NOTNULL,
CONSTRAINT [PK_Customer] PRIMARYKEYCLUSTERED
(
[CustomerID] ASC
)WITH (PAD_INDEX =OFF,STATISTICS_NORECOMPUTE =OFF,IGNORE_DUP_KEY=OFF,
ALLOW_ROW_LOCKS =ON,ALLOW_PAGE_LOCKS =ON)ON [PRIMARY]
)ON [PRIMARY]
Creating WCF Data Service In this step we will be creating a WCF Data Service using VS2010. This is currently targeting .NET 3.5 SP1. Step 1: Open VS2010 and create a blank solution. Name it as ‘SILV4_DataGrid_DML’. To this solution add a ‘WCF Service Application’ project, name it as ‘WCF_DMLService’. Since we are going to use WCF Data Service, we do not more require the interface ‘IService1’ and ‘Service1.svc’, so delete both these files. Step 2: In the service project, add a new ADO.NET Entity Data Model, name it as ‘CompanyEDMX.edmx’. Complete the Wizard. Select SQL Server connection to ‘Company’ database and select ‘Customer’ table. After the completion of the wizard, you will find the following .edmx generated. Read more: dot Net curry.com
I have also used a SQL Server 2008 database and the Database name is ‘Company’ with a table ‘Customer’. The DDL statement is as below:CREATETABLE [dbo].[Customer](
[CustomerID] [int] NOTNULL,
[CustomerName] [varchar](50)NOTNULL,
[Address] [varchar](50)NOTNULL,
[City] [varchar](50)NOTNULL,
[State] [varchar](50)NOTNULL,
[Age] [int] NOTNULL,
CONSTRAINT [PK_Customer] PRIMARYKEYCLUSTERED
(
[CustomerID] ASC
)WITH (PAD_INDEX =OFF,STATISTICS_NORECOMPUTE =OFF,IGNORE_DUP_KEY=OFF,
ALLOW_ROW_LOCKS =ON,ALLOW_PAGE_LOCKS =ON)ON [PRIMARY]
)ON [PRIMARY]
Creating WCF Data Service In this step we will be creating a WCF Data Service using VS2010. This is currently targeting .NET 3.5 SP1. Step 1: Open VS2010 and create a blank solution. Name it as ‘SILV4_DataGrid_DML’. To this solution add a ‘WCF Service Application’ project, name it as ‘WCF_DMLService’. Since we are going to use WCF Data Service, we do not more require the interface ‘IService1’ and ‘Service1.svc’, so delete both these files. Step 2: In the service project, add a new ADO.NET Entity Data Model, name it as ‘CompanyEDMX.edmx’. Complete the Wizard. Select SQL Server connection to ‘Company’ database and select ‘Customer’ table. After the completion of the wizard, you will find the following .edmx generated. Read more: dot Net curry.com
0 comments:
Post a Comment