How to insert update delete in datagridview c# or vb.net

Опубликовано: 10 Май 2026
на канале: Computer Science lectures and tutorials
1,368
3

insert update delete in gridview c# or vb datagrid view

hi, lets see how to add/delete/edit a value in datagridview in .net.

first we will add a row in datagridview
.rows.add -this will add new row into the datagridview

then we will now design the datagridview (columns)
once the add method is called, a new row is added at the end of the
datagridview.
the newly added row has the index count-1.
we will add two columns.
so we will get 2 values from user
.Rows.Item(.Rows.Count - 1).Cells.Item(0).Value = v1
.Rows.Item(.Rows.Count - 1)-represents the newly added row
.Cells.Item(0).Value represents first cell value in newly added row
.Cells.Item(1).Value represents second cell value in newly added row

now we will delete a row.
before delete we should find whether a row is selected or not
this can be done using a if check
this if statement finds the first row which is selected
now we have to delete the row
the deletion is completed.

lets now implement the find and edit functionallity
in this part, we will get the sno and edit the other value.
first get the sno and search if present.
the find procedure is implemented.
lets get a new value and replace the old value.
done, lets check.
the problem is we have set the auto insert.
thanks for watching. Kindly subscribe our channel.