I am sure your title should be "a global variable, I do not have the data I want." The dictionary will be built every time the page loads (postback or otherwise), but because of this line:
if(!isPostBack) { }
it will not have the necessary data when the button is pressed.
To notify the page of the click, a post-response is executed, therefore !isPostBack (which I assume is installed somewhere through Page.IsPostBack ) also says: “If I didn’t click the button”, which, of course, is not what Do you want to.
To get the necessary functionality, you must either move the dictionary population from this if block, or have an else condition that also fills it with the necessary data.
Another alternative to using a class variable is storing data in another place. Parameters include ViewState , Session , Application (if this is really application data), Cache and some others. It is not clear what exactly the dictionary does, so it’s hard to say which place will be the most suitable.
source share