Validation null values (preconditions) I would like to know an alternative, more elegant way to write the following methods.

I am especially not enthusiastic of the nested if statement or if for validate null values.

Now there are 3 if statement for null validation.

Any method:    

   private void LoadAlertas()
        {
            // *** OMITTED ***

            // Nullable object must have a value
            var PortalUser = HttpContext.Current.User.PortalUser();
            if (string.IsNullOrWhiteSpace(PortalUser)) throw new ArgumentNullException("HttpContext.Current.User.PortalUser is null");
            var personalData = PersonalData.getPersonalData(PortalUser);
            if (personalData == null) throw new ArgumentNullException("PersonalData.getPersonalData is null para " + PortalUser);
            if (!personalData.iID_PersonalData.HasValue) throw new ArgumentNullException("personalData.iID_PersonalData is null");

            var userLogado = Bll.PortalUser.getUsarioPortalByIdPersonalData(personalData.iID_PersonalData.Value);


Another method:    

 protected void Btn_Accion_Click(object sender, EventArgs e)
        {
            // *** OMITTED ***

            // Nullable object must have a value
            var PortalUser = Page.User.PortalUser();
            if (string.IsNullOrWhiteSpace(PortalUser)) throw new ArgumentNullException("Page.User.PortalUser is null");
            var personalData = MyPortal.AdminManager.Bll.PersonalData.getPersonalData(PortalUser);
            if (personalData == null) throw new ArgumentNullException("PersonalData.getPersonalData is null para " + PortalUser);
            if (!personalData.iID_PersonalData.HasValue) throw new ArgumentNullException("personalData.iID_PersonalData is null");

            var userLogado = MyPortal.AdminManager.Bll.PortalUser.getUsarioPortalByIdPersonalData(personalData.iID_PersonalData.Value);
            var userConsultado = setuserConsultado();
Why are you using ArgumentNullException? PortalUser isn't an argument, personalData isn't an argument, etc.




PortalUser should be camelcase. 
getPersonalData should be PascalCase. Ditto getUsarioPortalByIdPersonalData. Ditto setuserConsultado (and "User" should be capitalized).
iID_PersonalData should be PascalCase; moreover it seems to be using Hungarian notation which is against the C# standards, and it contains an underscore which is also against the C# standards.




I can't say much about the code, since there's so little of it. It doesn't look that good, to be honest, and I'd certainly move it to a specific method since both blocks seems to be part of a much longer method.