ADO.NET problem with report & edit button creating in datagridview .

Jan 3 2021 3:52 PM
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex != -1 && e.ColumnIndex != -1 && dataGridView1.Rows.Count > e.RowIndex + 1)
{
var v = dataGridView1.Rows[e.RowIndex].Cells["CvID"].Value;
CvID = dataGridView1.Rows[e.RowIndex].Cells["CvID"].Value == null ? 0 : Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["CvID"].Value);
//if ("Report" == dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString())
//{
// Form2 f2 = new Form2();
// f2.Show();
//}
if ("Edit" == dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString())
{
Edit();
}
if ("Delete" == dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString())
{
//Delete();
}
}
}
 
 
 
 
SHOWING THAT COLUMNNAME CvID cannot found, for your consideration data insert works good. 

Answers (2)