Updating database using datagridview in vb net
In this method, we have to get changed values of Text Box and Drop Down list and also we need the primary key value for the record that is being edited.
To get the Primary key, I have used Data Keys property of the Grid View with the index of the row, being edited and stored into a integer variable after parsing.
When Delete link of the Grid View will be clicked, it will confirm the user whether they really want to Delete the record, if they will click OK, it will fire On Row Deleting event of the Grid View that will call Delete Record method.
In this method again, I am getting the primary key value using Data Keys property of the Grid View and using it to delete the records from the database.
Selecting rows in the master table causes the detail table to update with the corresponding child data.
Then I have several methods attached with following events Get video of hundreds of ASP. On Row Editing - Edit Record On Row Cancel Edit - Cancel Record On Row Updating - Update Record On Row Deleting - Delete Record As I set Auto Generate Columns property to false so I am going to manually write the fields name that I need to appear in the way I want.
So I have to specify how I want them to appear in the normal view and edit view.
Implementing a master/detail form is easy using the interaction between the Data Grid View control and the Binding Source component.
In this walkthrough, you will build the form using two Data Grid View controls and two Binding Source components.In this method, I am specifying the Edit Index property of the Grid View to the New Edit Index of the Grid View and then calling Bind Data() method again to bind the data.Please note that when you will not bind the data again, Grid View will not change in edit mode.When Cancel link is clicked on Grid View in edit mode, On Row Canceling Edit event will fire that will call Cancel Record method.