title: Databound controls and UpdatePanel
body: <p>I have the following code:</p>
  
  <pre><code>&lt;asp:FormView ID="PhotoFormView" runat="server" DataKeyNames="PhotoID" DataSourceID="PhotoDataSource"&gt;
      &lt;EmptyDataTemplate&gt;
          No photo here.
      &lt;/EmptyDataTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Panel runat="server" Width='&lt;%#PhotoController.FullPhotoSize.Width%&gt;' Style="float: left;"&gt;
              &lt;asp:UpdatePanel runat="server" UpdateMode="Conditional"&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:Button ID="VoteButton" runat="server" OnClick="VotePhoto" /&gt;
                      &lt;asp:Literal ID="VoteCountLL" runat="server" Text='&lt;%#Bind("VoteCount")%&gt;' /&gt;
                      likes &lt;span style="float: right;"&gt;
                          &lt;asp:Button runat="server" Text="Previous" /&gt;
                          &lt;asp:Button runat="server" Text="Next" /&gt;
                      &lt;/span&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>In the VotePhoto method (in the code behind) invoked by the VoteButton button, I try to call DataBind on VoteCountLL, but I receive an InvalidOperationException with the message "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.".</p>
  
  <p>In English, here's what I am trying to do: I have a label showing the number of times a photo has been voted for. The button can be clicked to have the currently logged in user vote for the photo, thus increasing the vote count, which happens in the VotePhoto method. At the end of the VotePhoto method, it tries to call DataBind on the VoteCountLL literal to update the count, and it causes the aforementioned exception. How can I overcome this issue?</p>