title: Viewstate lost on postback for .net Sitecore page
body: <p>I'm getting some strange behaviour with viewstate being lost on postback for a .net application using Sitecore. I'm assuming it might be some config variable somewhere but I'm new to Sitecore and don't really know where to start looking.</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> Sitecore has now gotten back to us with an answer. We had recently added the dtSearch module, and AutomaticDataBind was set to true in the dtSearch.config which overrides the setting in the web config. We've now removed it and it works fine again.</p>
  
  <hr>
  
  <p>I've made a mini test if that might help. It's two usercontrols on one page, both with a repeater. When updating the viewstate gets lost so even if I'm binding the updated repeater again the data for the other one will be lost.</p>
  
  <p>Usercontrol 1:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;asp:Repeater runat="server" ID="Repeater1" OnItemDataBound="Repeater1_ItemBind"&gt;
   &lt;ItemTemplate&gt;
    &lt;li&gt;
     &lt;asp:Literal runat="server" ID="Literal1"&gt;&lt;/asp:Literal&gt;
    &lt;/li&gt;
   &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <pre class="lang-cs prettyprint-override"><code>protected void Page_Load(object sender, EventArgs e)
  {
   if (!IsPostBack)
   {
    List&lt;string&gt; myTestList1 = new List&lt;string&gt;();
    myTestList1.Add("a");
    myTestList1.Add("b");
  
    Repeater1.DataSource = myTestList1;
    Repeater1.DataBind();
   }
  }
  
  protected void Repeater1_ItemBind(object sender, RepeaterItemEventArgs e)
  {
   Literal Literal1 = (Literal)e.Item.FindControl("Literal1");
   Literal1.Text = (string)e.Item.DataItem;
  }
  </code></pre>
  
  <p>Usercontrol 2:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;asp:Repeater runat="server" ID="Repeater2" OnItemDataBound="Repeater2_ItemBind" OnItemCommand="Repeater2_Command"&gt;
   &lt;ItemTemplate&gt;
    &lt;li&gt;
     &lt;asp:Literal runat="server" ID="Literal2"&gt;&lt;/asp:Literal&gt;
  
     &lt;asp:LinkButton ID="Update" CommandName="Update" runat="server"&gt;
      update
     &lt;/asp:LinkButton&gt;
    &lt;/li&gt;
   &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <pre class="lang-cs prettyprint-override"><code>private string test = String.Empty;
  
  protected void Page_Load(object sender, EventArgs e)
  {
   if (!IsPostBack)
   {
    test = "a";
  
    Repeater2.DataSource = test;
    Repeater2.DataBind();
   }
  }
  
  protected void Repeater2_ItemBind(object sender, RepeaterItemEventArgs e)
  {
   char c = (char)e.Item.DataItem;
  
   Literal Literal2 = (Literal)e.Item.FindControl("Literal2");
   Literal2.Text = c.ToString();
  }
  
  
  protected void Repeater2_Command(object sender, RepeaterCommandEventArgs e)
  {
   if (e.CommandName == "Update")
   {
    test = "b";
  
    Repeater2.DataSource = test;
    Repeater2.DataBind();
   }
  }
  </code></pre>
  
  <p>Does anyone have any ideas what might be going on? Let me know if I need to provide any more information. The most annoying thing is that it was working last week but I have no idea what has changed!</p>
  
  <p>Thanks,</p>
  
  <p>Annelie</p>