This is the sample code for deleting selected rows from datagridview
using c#
private void Form1_Load(object sender, EventArgs e)
{
string constr = "Server = BUS-6A4CE2BF757; Database= master;Integrated Security = True;";
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("select * from emptable", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
// dataGridView1.DataBind();
}
private void button1_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow dr in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(dr);
}
}