Each time when pressing tree node then selectegNodeChanged event triggered and page is reloaded.So, i lost some data stored in Dictionary,ArrayList…How to prevent those data losing?
So, I stored those Dictionary and ArrayList as “static”.It is now resolved my problem.
Is it good way to do that?
No. Do not use
static. Try to store these inViewStateorSessioninstead.You can consider
ViewStateif it is not a large amount of data.staticwill be accessible acrossSessionand is not a good practice.You can create properties and avoid code duplication like shown below.
Now, when you want to re-assign data, read
TreeNodeDataListproperty. If count of thatArrayListis0, fetch from DB, else use it.Hope I am clear enough.