Last post Apr 27, 2021 07:18 AM by PatriceSc
Apr 27, 2021 06:12 AM|ubaidlove54|LINK
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
if (e.RowIndex != -1 && e.ColumnIndex != -1)
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
staffID = Convert.ToInt32(row.Cells["userIDGV"].Value.ToString());
nameTxt.Text = row.Cells["nameGV"].Value.ToString();
usernameTxt.Text = row.Cells["usernameGV"].Value.ToString();
passTxt.Text = row.Cells["passwordGV"].Value.ToString();
cpassTxt.Text = row.Cells["passwordGv"].Value.ToString();
p1Txt.Text = row.Cells["phone1GV"].Value.ToString();
p2Txt.Text = row.Cells["Phone2Gv"].Value.ToString();
roleDD.SelectedItem = row.Cells["RoleGV"].Value.ToString();
statusDD.SelectedItem = row.Cells["Status"].Value.ToString();
var im = (from x in obj.staffs where x.st_id == staffID select x.st_image).First();
if (im == null)
Apr 27, 2021 07:18 AM|PatriceSc|LINK
For now the code doesn't show how obj is declared or initialized? It's likely best to start by looking at which error message your have rather than to guess from the code.
Do you have a compile time error or a NullReferenceException ?
Edit: in short it seems that obj is not declared or if declared not initialized to a non null value. Could be still any other issue (a wrong connection to the db etc..). The purpose of errror messages is to tell you which bad thing happens and ti would
be best to always start from the error message.