Click here to Skip to main content
16,012,116 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi
i am design a window base application in c# .net, and i use a datagirdview in this datagirdview one column is check box when i select a paritucular checkbox row is delete in database and datagirdview both
Posted

so yo just need to delete the row in your database bye a stored procedure for delete the row by a specific value and then fetch your table again and fill it to data grid view
 
Share this answer
 
so yo just need to delete the row in your database by a stored procedure for delete the row by a specific value and then fetch your table again and fill it to data grid view
 
Share this answer
 
Try this Code:
C#
if (dataGridView1.Rows.Count > 1 && dataGridView1.SelectedRows[0].Index != dataGridView1.Rows.Count - 1)
{
delcmd.CommandText = "DELETE FROM table_Name WHERE Column_Name=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "";
con.Open();
delcmd.Connection = con;
delcmd.ExecuteNonQuery();
con.Close();
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
}
 
Share this answer
 
v3

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