Try this
for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
{
try
{
SqlCommand cmd = new SqlCommand("Delete from calender where ID='" + dataGridView1.SelectedRows[i].Cells[2].Value + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
dataGridView1.Rows.RemoveAt(i);
}
foreach(DataGridViewRow dr in dataGridView1.SelectedRows)
{
try
{
SqlCommand cmd = new SqlCommand("Delete from calender where ID='" + dr.Cells[2].Value + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
dataGridView1.Rows.RemoveAt(i);
}