I am trying to store an integer variable and make it persist in between post backs as follows:
private int imad;
// Inside Page_Load() I have this:
// Read val
if(this.ViewState["val"] == null)
{
val= 10;
}
else
{
val= (int)this.ViewState["val"] + 1;
}
// Store val
this.ViewState["val"] = val;
My problem is that at beginning of Page_Load()
ViewState["val"] is always = null. This means it is not persisting between post backs.
Please let me know if you have answer.
Thanks to all.