title: Removing items from databound listview : Possible bug?
body: <p>Can I not remove items from a databound listview?</p>
  
  <p>I bind the list view to a collection of users. lets say the listview is displaying name/address from the test object. If I try to remove the first item as below, it still displays all the records in the collection. This does not serve any good purpose. I just want to know what am I missing.</p>
  
  <p>I'm suspecting it is because the datasource is still pointing to the collection which is unchanged. but if I manually change the listview items, shouldn't it take precedence?</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
         lvTest.DataSource = new List&lt;TestObj&gt;{ obj1, obj2..}; //pseudo code
         lvTest.DataBind();
  
         lvTest.Items.RemoveAt(0);
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I understand this is not a good way of doing this. But the purpose of this question is to know why this does not work.</p>
  
  <p>I think this might be a bug in the listview control. If you check the items count in the debugger after the first item is removed, you can see that the actual count is reduced by 1, but it still renders it. </p>
  
  <p>Also, if you did <code>lvTest.Items[0].Visible = false;</code> after the <code>RemoveAt(0)</code>, it actually makes the second item invisible which means that listview considers the first item removed but renders it regardless.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>On request, markup and codebehind used for test are below.</p>
  
  <pre><code>&lt;asp:ListView ID="lvTest" runat="server" &gt;
              &lt;LayoutTemplate&gt;&lt;asp:PlaceHolder ID="itemPlaceholder" runat="server" /&gt;&lt;/LayoutTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;div&gt;&lt;%# Eval("CompanyName")%&gt;&lt;hr /&gt;&lt;/div&gt;
              &lt;/ItemTemplate&gt;
              &lt;EmptyDataTemplate&gt;&lt;div&gt;None&lt;/div&gt;&lt;/EmptyDataTemplate&gt;
          &lt;/asp:ListView&gt;
  
  
  protected void Page_Load(object sender, EventArgs e)
          {
              lvTest.DataSource = GetCompanyList();
  
              lvTest.DataBind();
  
              lvTest.Items.RemoveAt(0);
  }
  
  
  
  public static List&lt;Company&gt; GetCompanyList()
          {
              List&lt;Company&gt; c = new List&lt;Company&gt;();
  
              Company c1 = new Company();
              c1.CustomerID = "2122";
              c1.ContactName = "testc1";
              c1.CompanyName = "test2";
  
              Company c2 = new Company();
              c2.CustomerID = "2123";
              c2.ContactName = "testc2";
              c2.CompanyName = "test2";
  
              c.Add(c1);
              c.Add(c2);
  
              return c;
          }
  </code></pre>