Click here to Skip to main content
15,998,100 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to delete row from datagridview in vb.net and from access database without appending data to textbox means on select row from datagrid and click delete opertaion.

What I have tried:

If DataGridView1.SelectedRows.Count > 0 Then

'Label lblID= (Label) dataGridView1.SelectedRows[0].FindControl("lblPrimaryKey");
'SqlCommand cmd = new SqlCommand ("Delete from table where id='"+ Convert.ToInt32(lblID.Text)+"'",ConnectionObject);
'cmd.ExecutenonQuery();
' End If
Posted
Updated 5-Mar-18 2:42am

1 solution

If my assumption is correct, that data is deleted from the database but still is visible in your DataGridView, then I would suggest that you either:
1) rerun the query that filled your view (Datasource) initially
2) remove the deleted item from the datasource used for the DataGridView

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900