Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
6
Reply
Column named cannot be found?
Resign Designs
Jun 22 2015 3:04 AM
1.5k
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
how to display same value in dropdownlist in edit mode of gr
how to make a collection of multiple custom controls in c#