title: Delete image from repeater control in asp.net
body: <p>I have a repeater control to display images. Below every images I have placed a button for deleting the image. I want the image to get removed from the repeater control on pressing that delete button. I tried everywhere to find this but i didn't get the solution. Thanks in advance. 
  Here is my code:</p>
  
  <pre><code>&lt;asp:Repeater ID="FileRepeater" runat="server" OnItemCommand="RepeaterCommand"&gt;
      &lt;ItemTemplate&gt;
          &lt;div style="float: left; overflow: hidden; display: inline-block;"&gt;
              &lt;asp:Image ID="Image1" runat="server" Style="height: 200px; width: 200px; border: 1px solid gray;" ImageUrl="&lt;%# Container.DataItem %&gt;" /&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="btnDelete" runat="server" Width="80px" Text="Delete" CommandName="delete" UseSubmitBehavior="false" /&gt;
          &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  
  protected void RepeaterCommand(object source, RepeaterCommandEventArgs e)   
  {       
      RepeaterItem itemToRemove = e.Item;
      String sessionItemToRemove = itemToRemove.ToString();
      Console.WriteLine("%c", sessionItemToRemove);
      Session.Remove(sessionItemToRemove);     
  }
  
  protected void Page_Load(object sender, EventArgs e)
  {
      string[] list = Directory.GetFiles(Server.MapPath("images"));
      List&lt;String&gt; images = new List&lt;string&gt;(list.Count());
  
      foreach (string item in list)
      {
          images.Add(String.Format("~/Images/{0}", System.IO.Path.GetFileName(item)));
      }
  
          FileRepeater.DataSource = images;
          FileRepeater.DataBind();
  
  }
  </code></pre>