title: How to re-bind ListView on OnClick event of a button?
body: <p>this seemed simple at first but I can't get it to work.</p>
  
  <p>I have the following scenario:</p>
  
  <pre><code>        &lt;asp:ListView ID="CommentsListView" runat="server"&gt;
              &lt;LayoutTemplate&gt;
                      &lt;asp:PlaceHolder ID="itemPlaceholder" runat="server" /&gt;
              &lt;/LayoutTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;UC:Comment runat="server" CommentItem="&lt;%# CurrentComment %&gt;" /&gt;
                  &lt;br /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:ListView&gt;
          &lt;asp:TextBox ID="NewComment" runat="server" /&gt;
          &lt;asp:ImageButton ImageUrl="/images/ball.png" runat="server"
                        OnClick="SubmitComment" /&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
           RenderListView();
      }
  
      protected void RenderListView()
      {
          CommentsListView.DataSource = //Get the data source objects
          CommentsListView.DataBind();
      }
  
      protected CommentObject CurrentComment
      {
          get { return (CommentObject)Page.GetDataItem(); }
      }
  
      protected void SubmitComment(object sender, ImageClickEventArgs e)
      {   
          //code to submit comment
  
          RenderListView();
      }
  </code></pre>
  
  <p>basically, when I submit a comment, I want to see it in the ListView, but I don't. "MyControl" gets a null comment in the post-back, for all of the items (not just the new one).</p>
  
  <p>Only after I refresh the page, I can see the new comment that I'v submitted. I can't however refresh the page every submit because this code is inside an UpdatePanel (the issue occurs without the UpdatePanel as well).</p>
  
  <p>Any idea how to solve this?</p>