I have a DataGridView that has binding with user class and text boxses the has a binding with each property of the class. My problem is that after clicking on cell the textboxes shows the row values but when I try to save the class has all the properties as null. this is my code:
User user = new User();
private void UcUsers_Load(object sender, EventArgs e)
{
UserdataGridView.DataSource = LibraryManagment.getDBUsers();
userBindingSource.DataSource = user;
}
private void UserdataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
UserdataGridView.CurrentRow.Selected = true;
userIdBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersIdDataGridViewTextBoxColumn"].Value.ToString();
fnameBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersFirstNameDataGridViewTextBoxColumn"].Value.ToString();
lnameBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersLastNameDataGridViewTextBoxColumn"].Value.ToString();
unameBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersUserNameDataGridViewTextBoxColumn"].Value.ToString();
passwordbox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersPasswordDataGridViewTextBoxColumn"].Value.ToString();
enailBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersEmailDataGridViewTextBoxColumn"].Value.ToString();
roleCmb.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersRoleDataGridViewTextBoxColumn"].Value.ToString();
phoneBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersPhoneDataGridViewTextBoxColumn"].Value.ToString();
tzBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["userTzIdDataGridViewTextBoxColumn"].Value.ToString();
addressBox.Text = UserdataGridView.Rows[e.RowIndex].Cells["usersAddressDataGridViewTextBoxColumn"].Value.ToString();
}