title: Repeater in my user control is empty on postback
body: <p>I've looked at a lot of similar questions here, but to no avail.</p>
  
  <p>So here goes...</p>
  
  <p>I'm creating a set of user controls that display a list of grid-like tables.  Anyway, the objective is to list the grids, mess with the each grids data (client-side) and press save.  The grids work great, but when I press save teh repeater in the VIEWER is always empty.  Any help appreciated!</p>
  
  <p><strong>The Basic Layout Goes Like This</strong></p>
  
  <ol>
  <li>PAGE</li>
  <li>...updatePANEL</li>
  <li>......usercontrolVIEWER</li>
  <li>.........saveBUTTON</li>
  <li>.........repeaterCONTROL</li>
  <li>............usercontrolGRID</li>
  <li>............usercontrolGRID</li>
  <li>............ETC!</li>
  </ol>
  
  <p><strong>The PAGE Looks Like This</strong></p>
  
  <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server"&gt;
      &lt;asp:UpdatePanel id="udPanel" UpdateMode="Always" runat="server"&gt;
              &lt;Triggers&gt;
              &lt;/Triggers&gt;
              &lt;ContentTemplate&gt;
                 &lt;uc:CommitImporterView ID="civData" runat="server" /&gt;
              &lt;/ContentTemplate&gt;
      &lt;/asp:UpdatePanel&gt;
  &lt;/asp:Content&gt;
  
  public partial class CommitsAndActualsImporter : BaseForm
  {
      #region EVENTS
  
      protected void Page_Init(object sender, EventArgs e)
      {
          setUpEventHandlers();
  
          if (!IsPostBack)
              initalize();
      }
      protected void Page_Load(object sender, EventArgs e)
      {
      }
  
      protected void myListOfGroups_DataBinding(object sender, EventArgs e)
      {
          //.. Code to bind the list goes here ...
  
          myListOfGroups.SelectedIndex = setSelectedIndex(collection);
      }
      protected void myListOfGroups_SelectedIndexChanged(object sender, EventArgs e)
      {
          myGroup = myListOfGroups.Find(selectedItem =&gt; selectedItem.Key == key);
          dataSource = buildViewDataSource(base.ProjectKey, base.AsOf, myGroup.FcrGroupKey, myGroup.ContractorKey, myGroup.WbsKey);
  
          civData.AsOf = base.AsOf;
          civData.ProjectKey = base.ProjectKey;
          civData.DataSource = dataSource;
          civData.DataBind();
      }
  
      #endregion
  
      #region METHODS
  
      private void initalize()
      {
          ContractorInviteItems dataSource = listGroups(ProjectKey, AsOf);
          myListOfGroups.DataSource = dataSource;
          myListOfGroups.DataBind();
      }
      private void setUpEvents()
      {
          myListOfGroups.DataBinding += new EventHandler(myListOfGroups_DataBinding);
          myListOfGroups.SelectedIndexChanged += new EventHandler(myListOfGroups_SelectedIndexChanged);
      }
  
      #endregion
  }
  </code></pre>
  
  <p><strong>The VIEWER User Control Looks Like This</strong></p>
  
  <pre><code>&lt;%@ Register Src="~/UserControls/CommitImporterGrid.ascx" TagName="CommitImporterGrid" TagPrefix="uc" %&gt;
  
  &lt;asp:Button ID="btnSave" runat="server" Text="Save" /&gt;
  
  &lt;asp:HiddenField ID="hidAsOf" runat="server" Value="" /&gt;
  &lt;asp:HiddenField ID="hidProjectKey" runat="server" Value="0" /&gt;
  
  &lt;asp:Repeater ID="repCommitImporterView" runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;uc:CommitImporterGrid runat="server" /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  public partial class CommitImporterView : System.Web.UI.UserControl
  {
      #region PROPERTIES &amp; FIELDS
  
      private enum basisUsed
      {
          Dollars,
          Hours,
          IsInvalid
      }
  
      public Object DataSource { get; set; }
  
      public DateTime AsOf { get { return Convert.ToDateTime(hidAsOf.Value); } set { hidAsOf.Value = value.ToString(); } }
      public Int32 ProjectKey { get { return Convert.ToInt32(hidProjectKey.Value); } set { hidProjectKey.Value = value.ToString(); } }
  
      #endregion
  
      #region EVENTS
  
      protected override void OnInit(EventArgs e)
      {
          base.OnInit(e);
          setupEvents();
      }
      protected override void OnLoad(EventArgs e)
      {
          base.OnLoad(e);
          this.DataBind();
      }
      protected override void OnPreRender(EventArgs e)
      {
          base.OnPreRender(e);
      }
  
      public override void DataBind()
      {
          base.DataBind();
      }
  
      protected void btnSave_Click(object sender, EventArgs e)
      {
          Int32 count = repCommitImporterView.Controls.Count;
  
          foreach (Control control in repCommitImporterView.Controls)
          {
              if (control is UserControls.CommitImporterGrid)
              {
                  string stop = "";
              }
  
          }
      }
  
      protected void repCommitImporterView_DataBinding(object sender, EventArgs e)
      {
          if (DataSource == null)
              return;
  
          if (!IsPostBack)
          {
              Decimal totalSummaryCbudDollars = 0;
              Decimal totalSummaryCbudHours = 0;
  
              if (summaryValuesExist(out totalSummaryCbudDollars, out totalSummaryCbudHours))
                  alignSummarizedRecords(totalSummaryCbudDollars, totalSummaryCbudHours);
  
              repCommitImporterView.DataSource = DataSource;
          }
      }
      protected void repCommitImporterView_ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
          ContractorInviteCommitsAndActualsImport record = (ContractorInviteCommitsAndActualsImport)e.Item.DataItem;
          CommitImporterGrid grid = new CommitImporterGrid();
          grid = (UserControls.CommitImporterGrid)Page.LoadControl("~/UserControls/CommitImporterGrid.ascx") as UserControls.CommitImporterGrid;
  
          grid.AsOf = this.AsOf;
          grid.ProjectKey = this.ProjectKey;
  
          grid.DataSource = getDataSource(record);
          grid.DataBind();
  
          repCommitImporterView.Controls.Add(grid);
      }
  
      #endregion
  
      #region METHODS
  
      private void setupEvents()
      {
          btnSave.Click += new EventHandler(btnSave_Click);
  
          repCommitImporterView.DataBinding += new EventHandler(repCommitImporterView_DataBinding);
          repCommitImporterView.ItemDataBound += new RepeaterItemEventHandler(repCommitImporterView_ItemDataBound);
      }
  
      #endregion
  }
  </code></pre>
  
  <p><strong>The GRID User Control Looks Like</strong></p>