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
Scott G
NA
103
7.8k
Delete from database using datagrid
Dec 14 2018 9:27 AM
I have a datagrid that is displaying the contents of a SQL table. I am trying to add a button that will delete the selected row from the datagrid. I found the following that allows me to remove it from the grid but it is not removing it from the table of course. I am drawing a blank on how to remove from the grid and the underlying table.
foreach (DataGridViewRow row in myGrid.SelectedRows)
if (!row.IsNewRow) myGrid.Rows.Remove(row);
int selectedCount = myGrid.SelectedRows.Count;
while (selectedCount > 0)
{
if (!myGrid.SelectedRows[0].IsNewRow)
myGrid.Rows.RemoveAt(myGrid.SelectedRows[0].Index);
selectedCount--;
}
Reply
Answers (
2
)
split values in multiple column in c# windows application
splitting string into array of strings