TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
priyanka
NA
215
123.2k
delete rows in datagridview in c#
Aug 11 2018 1:14 AM
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.
Reply
Answers (
14
)
hello ,can someone convert these code in asp.net webform c#
SelectCommand.Connection property has not been initialized.