I am trying to delete a user through his ID by selecting a cell/row in the DataGridview and then clicking on the delete button. I tried to get the ID by using the row index and column index. However, I am not able to delete the user as the value of 'string id' is NULL even when my datagridview contains rows.
private void buttonDeleteUser_Click(object sender, EventArgs e)
{
int rowindex = dataGridView1.CurrentCell.RowIndex;
int columnindex = 0;
string id = dataGridView1[rowindex, columnindex].Value.ToString();
controller_employee.delete_employee(Int32.Parse(id));
}
Why is it NULL and what can I do to resolve this?