Thursday 29 August 2013

GRIDVIEW ENTITY DATASOURCE EDIT DELETE OPERATIONS

GRIDVIEW and ENTITY DATASOURCE  EDIT DELETE OPERATIONS


1)  Create Website
2) Add aspx page
3) Drag and Drop GridView
4) Add EntityDataSource

5)  Before adding Entity Data Source 
                  Add Entity Data Modal Support for ur Application. Pls use this link

6) Before adding  Entity Data Modal to ur Project,  pls create table called Products


CREATE TABLE [dbo].[Products](
[PK_ProductID] [bigint] IDENTITY(1,1) NOT NULL,
[ProductName] [varchar](50) NOT NULL,
[Brand] [varchar](50) NOT NULL,
[Price] [smallmoney] NOT NULL,
 CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED 
(
[PK_ProductID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


add some sample data to Products table
Insert some sample data into Products table then into Orders table

PK_ProductID ProductName Brand Price
1 Monitor LCD LG 100.00
2 Mouse Microsoft 30.00
3 Keyboard Wireless Siemens 66.00
4 External HDD Sea Gate 150.00
5 Web Cam 5mp Sony 80.00



Then add Entity Data Modal to ur project


6) Now  Add  Entity Data Source  Web Server control to aspx page.
   Select configure the DataSource

 




8)  Build the Project and Run it

9)  Delete also will work  , Here Iam showing only one table .Cascade Delete operations are not supported here(i.e if ProductID is a foreign key in orders/order details table then Delete Operation will throw an exception).

No comments:

Post a Comment