0
votes
  1. I have a web user control which has an update panel & a gridview is inside it
  2. On page load I set user control's private field value through a publicly exposed property & bind the gridview with data
  3. I enter some new values in through a modal & do a postback inside the updatepanel in user control, when I try to fetch the value of private field on my user control the value is default to zero
 private int ftId = 0;

public int  FtId
{
    set { ftId = value; }
}

the private int ftId=0; is called after every ASync postback. Is there any way I can overcome this problem ?

1

1 Answers

1
votes

You cannot store a value in a variable and have it persist across postbacks. But storing it in viewstate will work:

public int  FtId
{
    get { return  (int)(ViewState["FtId"] ?? 0); }
    set { ViewState["FtId"] = value; }
}

HTH.