Interesting variable name :laugh:
Anyway, the reason you're getting a NullReferenceException probably lies in the previous line:
TB_MasterCompanyDepartment AssDepartment = CDbde.TB_MasterCompanyDepartments.FirstOrDefault(C => C.mCDP_NUPKId == mobjGenlib.ConvertLong(DepartmentID.Text));
Either
TB_MasterCompanyDepartments
is an empty collection, or the value of
DepartmentID.Text
does not match any
mCDP_NUPKId
value.
Step through your code with a debugger and it's pretty easy to spot what the problem is here. And either way it's entirely valid for
AssDepartment
to be null, so test it and handle it accordingly.