In short, you had to modify the product's value from 1 to 4.Likewise, the simplified interface lacks any input validation that may be necessary when editing required fields or fields that must appear in a particular format (like dates or numbers). Find Control("cbo Brand"), Drop Down List) If cbo Brand Is Not Nothing Then ' You can apply condition here cbo Brand.In this article, we will explore how to add, update, delete and select a record from sql server database using gridview control in a simple way.Here we are not deleting a record permanently but using active flag column, make it inactive the record while doing the delete operation then make it active and get it whenever you want.In this article, I am going to explain how to manipulate data using Grid View control.
I have specified Data Key Names as Auto ID, the primary key of the database table.From the Visual Studio Designer, the Grid View can be marked as editable by checking the "Enable Editing" checkbox in the Grid View's smart tag or by manually adding a Command Field to the Grid View whose event.Title: Edit, Delete, Update Data in Grid view in using c#Description: As per previous articles we have seen how to export grid view data to excel in and how to bind data to drop down list in grid view.In practical scenario you should use your existing architecture to populate and update the data.In this article, I am going to take a simple database table that has following fields: Auto ID - Int, Auto Increment, Primary Key Page Name - Varchar(50) Page Description - Varchar(500) Active - Bit(1) In this article, I am not going to explain the workings of Sql objects but focusing on the events and methods of the Grid View that will help us in updating and deleting the records.
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) Protected Sub Page_Load(sender As Object, e As System. Load If Not Is Post Back Then Bind Grid View() End If End Sub Private Sub Bind Grid View() Dim dt As Data Table Dim SQL As [String] = "SELECT P.