Makes sense that they would be 0, because you never set 'studentid', so they retain their implicit value (which is zero). Not seeing the full code, it would seem that 'studentid' is unnecessary, and you should just use 'studentID'. What purpose is served by having both of them? (As an aside, I would urge you not to have two fields with the same name that only differ in case; it's much too easy to make mistakes through typos).
I was advised to have two variables, one of which should be static.
You really want this to be two variables. One to keep track of the current maximum assigned student id and one to keep track of the student id for that particular student. Tip: Think about which one of these needs to be static.