//删除数据
private void btnDelete_Click(object sender, System.EventArgs e)
{
bool selectRow = false;
DataTable dtFind = (DataTable)dgShowData.DataSource;
string[] ids =new string[dtFind.Rows.Count];
for (int i = 0; i < dtFind.Rows.Count; i++)
{
selectRow = true;
if (dgShowData.IsSelected(i))
{
ids [i]= i.ToString(); //"; //1,4,6 where id in ( 1,4,6)
}
}
if (selectRow == false || ds.Tables["particular"].Rows.Count == 0)
{
MessageBox.Show("There are no data can be deleted!", "Delete notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (MessageBox.Show("Would you really delete current S/O data?", "Delete notice", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
for (int j = 0; j < ids.Length; j++)
{
if (ids[j] != null)
{
dtFind.Rows[(int)j].Delete();
}
}
}
}