pcphuc wrote:
How about field DepartmentID for this staff. How can I set value for it?
Because I can not set value for it normally
You don't need the ID. Assuming you have a persisted instance of Department, you simply assign it like the following:
Code:
Department dept = new Department();
sess.Save(dept);
st.Department = dept;
sess.Save(st);
Quote:
st.DepartmentID = dropdownlist1.SelectedValue; // It does not have DepartmentID property
You will do it this way:
Code:
st.Department = dropdownlist1.SelectedValue as Department;
Hope this helps