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
Resign Designs
NA
31
29.9k
Column named cannot be found?
Jun 22 2015 3:04 AM
Hi,
I have a datagridview and a delete button.When user select a row and click delete button (outside of the datagridview) it must delete relevant row from datagridview.
Right now it is working but sometime it throws this error
"Column named RecordID cannot be found" from below highlighted line
int selectedIndex = InternetGroupDGV.CurrentCell.RowIndex;
if (selectedIndex > -1)
{
int selectedrowindex = InternetGroupDGV.CurrentCell.RowIndex;
DataGridViewRow selectedRow = InternetGroupDGV.Rows[selectedrowindex];
string recID = Convert.ToString(selectedRow.Cells["RecordID"].Value);
SqlConnection con = new SqlConnection(this.configuration.Connstring);
SqlCommand deleteCMD = new SqlCommand("InternetGroup_Delete", con);
deleteCMD.CommandType = CommandType.StoredProcedure;
deleteCMD.Parameters.AddWithValue("@RecordID", recID);
con.Open();
deleteCMD.ExecuteNonQuery();
callDB(); //Bind
}
else
{
MessageBox.Show("Error Occured");
}
Seems me once it deleted a record it cannot find out RecordID to delete again.
Any ideas?
Thanks
Reply
Answers (
6
)
how to display same value in dropdownlist in edit mode of gr
how to make a collection of multiple custom controls in c#