The problem is because web pages are stateless. Your variable gets re-set back to it's original value with every post-back. This is normal behavior. After you set your variable in your addRecord method, you need to save it into a Session object so that it's persisted between post-backs.
~~Bonnie
>Hi Chad, sorry for confusing you.
>
>What I want is the addRecord calls whenever the page is NOT post back, else it will do other functions. The function called has no problem, and the value has been set as expected after the page load (without any user's action). I'm just confused that why the variable becomes NULL when I click a button to retrieve it's value which has been set in the Page Load function, thanks.