Code for rowupdating in gridview in c

Rated 3.87/5 based on 543 customer reviews

I will be using Sql objects directly into methods to keep the example simple and straight forward.

In practical scenario you should use your existing architecture to populate and update the data.

Open() Using da As New Sql Data Adapter(comm) dt = New Data Table("tbl") da.

This article scope is limited to Updating and Deleting records using Grid View and I am not using any readymade Data controls for that but manually writing all event methods.CREATE TABLE [dbo].[Brand]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NOT NULL, CONSTRAINT [PK_Brand] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] CREATE TABLE [dbo].[Product]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NULL, [Description] [varchar](max) NULL, [Brand ID] [bigint] NULL, CONSTRAINT [PK_Product_2] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] INSERT INTO Brand Values(1,'Kohinoor') INSERT INTO Brand Values(2,'Proctor & Gamble') INSERT INTO Brand Values(3,'Telenor') INSERT INTO Brand Values(4,'Unilever') INSERT INTO PRODUCT VALUES(1,'Lux Beauty Soap','Product of Unilever',4) INSERT INTO PRODUCT VALUES(2,'Tibbet Pomed','Winter Product',1) INSERT INTO PRODUCT VALUES(3,'Data SIM','Subscriber Identity Module',3) INSERT INTO PRODUCT VALUES(4,'Nippon','Color Television',1) Note: If you use windows authentication then use the first key. Update server name, Database name, User name, Password as per your settings. Now add the Grid View Control like Below: Protected Sub Page_Load(sender As Object, e As System. Load If Not Is Post Back Then Dim dt As Data Table Dim SQL As [String] = "SELECT P. before that i want just using Find control and casting and then retrieving all lot code. If values are same they could notify user to change the value(give new cell value). Every one can use it to compare the new value with old ones.

Leave a Reply