title: why controls inside a gridview (which is inside a user control) do not retain their properties' values after a postback?
body: <p>I have a page that has 5 user controls of the same typ. Each user control has a gridview and a couple of buttons.</p>
  
  <p>I don't understand why the controls on the user controls don't retain their value. </p>
  
  <h1>EDIT</h1>
  
  <p>Below is how I'm populating the gridview inside a user control.</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          var list = new List&lt;CKListByDprtment&gt;
          {
              new CKListByDprtment { ID = 1, TaskName = "New laptop needed", 
              CompletedBy = "My Boss", HMReq = true },
              new CKListByDprtment { ID = 2, TaskName = "New Workstation needed",
              CompletedBy = "My Boss", HMReq = false }
          };
  
          gvCKList.DataSource = list;
          gvCKList.DataBind();        
  
      }
      #endregion
  
      #region GridView Validation
      protected void cvValidateGrid_ServerValidate(object sender, ServerValidateEventArgs args)
      {
          ValidateGrid();
      }
  
      private void ValidateGrid()
      {
          foreach (GridViewRow gvRow in gvCKList.Rows)
          {
              CheckBox ckHMreq = gvRow.Cells[0].FindControl("ckHMreq") as CheckBox;
          }
      }
  </code></pre>
  
  <p>I tried to add a checkbox on the main aspx page. When the page posted back, the checked was able to retain its value. I tried also on the user control but not inside the gridview. When the postback, the checkbox retained its value. </p>
  
  <p>It looks like only inside the gridview where controls lose their values after a postback. I have added <strong>ViewStateMode = "Enabled"</strong> first on the aspx page, then on the usercontrol and finaly on the gridview itself, but with no success. </p>
  
  <p>Any reason?</p>