I want to delete some rows from datagridview based on condition in c#,but at run time i find that row,though by debugging my code is working properly.
My code is as follows:-
foreach (DataGridViewRow item in this.dataGridView1.Rows)
{
if ((item.Cells["Start Time"].Value.ToString() != "22:00:00") || (item.Cells["Start Time"].Value.ToString() != "18:00:00"))
{
dataGridView1.Rows.Remove(item);
}
}
dataGridView1.Rows.Remove(item);
Instead of this line,I have even tried
dataGridView1.Rows.RemoveAt(item.Index)
i have even tried to delete rows from datatable and then bind in datagridview ,but nothings helped me.
why my above code fails to delete record in datagridview,PLZ help me out.
Sirisha KPosted Sep 3, 2018, 4:07 AM
Karthik RamachandranPosted Sep 1, 2018, 1:55 AM
Rafnas T PPosted Aug 16, 2018, 2:13 AM
Sirisha KPosted Aug 14, 2018, 2:21 PM
priyankaPosted Aug 14, 2018, 4:36 AM
Kanimozhi ShivakumarPosted Aug 13, 2018, 7:39 AM
Yogesh GhorpadePosted Aug 13, 2018, 6:47 AM
Jignesh KumarPosted Aug 11, 2018, 10:51 AM
Jaish MathewsPosted Aug 11, 2018, 10:11 AM
ejaz mirzaPosted Aug 11, 2018, 2:30 AM
priyankaPosted Aug 11, 2018, 2:19 AM
ejaz mirzaPosted Aug 11, 2018, 2:14 AM
priyankaPosted Aug 11, 2018, 2:12 AM
ejaz mirzaPosted Aug 11, 2018, 2:01 AM