private void fnCheck(int flag, DateTime dt) { DataView dv = new DataView(); dv = ds.Tables[0].DefaultView; dv.Sort = "DateTime Asc"; DataRowView[] rows = dv.FindRows(dt); if (flag == 1) { if (rows.Length > 0) { MessageBox.Show("Already Alert has been created for this time , Choose other timings"); } else { DataRow dr = ds.Tables[0].NewRow(); dr["DateTime"] = dt.ToString(); dr["AlertMessage"] = textBox3.Text.Trim(); ds.Tables[0].Rows.Add(dr); ds.WriteXml(path); fnDatGridBind(); checkValid(); } } else { String d; if (rows.Length > 0) { d = rows[0][1].ToString(); taskbarNotifier1.Show1(d, 500, 500); ds.Tables[0].Rows.RemoveAt(dv.Find(rows[0][0])); ds.WriteXml(path); fnDatGridBind(); } } }