title: Why can't i access page viewstate in usercontrol?
body: <p>I stored a object in viewstate on Page. Now when i access the same viewsate object on usercontrol,it shows as null. I even tried creating the same viewstate with same name in usercontrol and page.Both holds different value.</p>
  
  <p>I understand that viewstate is a protected property. How does this thing implement in above scenerio or is there any other reason for this behaviour.</p>
  
  <p>Edit:</p>
  
  <p>Usercontrol is there in the page markup. I am not loading it dynamically.</p>
  
  <p>I have a page EditFacilityworkType.aspx. On page I have a usercontrol FacilityWorkTypeDetails.aspx(FacilityWorkTypeDetails1). Inside this usercontrol i have a user control Workflow.aspx(Workflow1)</p>
  
  <p>Page_Load() of Page
  I am retrieving workflowdetails on page_load() of page.</p>
  
  <pre><code> FacilityWorktype facilityWorkType = facilityDetails.GetFacilityWorktypeDetail(SessionHelper.FacilityWorkTypeID);
   ViewState["WorkFlow"] = facilityWorkType.FacilityWorkTypeWorkFlow
  </code></pre>
  
  <p>Inside usercontrol FacilityWorkTypeDetails.aspx. I have a property</p>
  
  <pre><code> public FacilityWorktype FacilityWorkTypeDetails
  {
      get
      {
          #region Fill FacilityWorktype
          return GetEntityFromControl();
          #endregion
      }
      set
      {
          PopulateControls(value);
      }
  }
  </code></pre>
  
  <p>Now i set this property in page load of page</p>
  
  <pre><code>FacilityWorkTypeDetails1.FacilityWorkTypeDetails = facilityWorkType;
  </code></pre>
  
  <p>Inside Workflow.aspx, I have a property</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Property to fill entity object from controls on this page
  /// &lt;/summary&gt;
  public WorkFlow WorkFlowDetails
  {
      get
      {
          return GetEntityFromControls();
      }
      set
      {            
          BindTranscriptionMethodDDL(ddlTranscMethod);
          PopulateControls(value);
      }
  }
  </code></pre>
  
  <p>Now PopulateControls() of FacilityWorkTypeDetails1, i am setting property of workflow1  </p>
  
  <p>private void PopulateControls(FacilityWorktype value)
      {</p>
  
  <pre><code>    Workflow1.WorkFlowDetails = value.FacilityWorkTypeWorkFlow;
  }
  </code></pre>
  
  <p>Now when i am retrieving values from </p>
  
  <pre><code> private WorkFlow GetEntityFromControls()
   {
       WorkFlow workFlow = (ViewState["WorkFlow"] as WorkFlow) ?? new WorkFlow();  
       //workFlow  is null
  
   }
  </code></pre>
  
  <p>So now inside this function workFlow  is null. I want to ask,why is it null when i have set viewstate in page.</p>