title: Form display message when all items have been deleted from list
body: <p>I am trying to delete items from a list that populates from a drop down list and  want the to display a message saying there are no items in the list once all items have been deleted. 
  The lines commented out should make it work however I cant seem to to get i right. 
  If anyone could help that would be appreciated.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>public partial class DeleteBook : System.Web.UI.Page
  {
  public Catalogue catalogueInstance = new Catalogue();
  
  //Filepath for json file
  const string FILENAME = 
  @"C:\Users\tstra\Desktop\19456932_CSE2ICX_Assessment_3\Bin\Books.json";
  
  
  protected void Page_Load(object sender, EventArgs e)
  {
      string jsonText = File.ReadAllText(FILENAME);
      // reading data contained in the json filepath
      //convert objects in json file to lists
      catalogueInstance = JsonConvert.DeserializeObject&lt;Catalogue&gt;(jsonText);
  
      if (IsPostBack) return;
  
      ddlDelete.DataSource = catalogueInstance.books;
      ddlDelete.DataTextField = "title";
      ddlDelete.DataValueField = "id";
  
      ddlDelete.Items.Insert(0, "There are no items in the Catalogue to 
  Display");
  
      //binding the data to Drop Down List
      ddlDelete.DataBind();
  }
  
  protected void ddlDelete_SelectedIndexChanged(object sender, EventArgs e)
  {
  
      string jsonText = File.ReadAllText(FILENAME);
      // reading data contained in the json filepath
      //convert objects in json file to lists
      catalogueInstance = JsonConvert.DeserializeObject&lt;Catalogue&gt;(jsonText);
  
      Book b = catalogueInstance.books[ddlDelete.SelectedIndex - 1];
      txtID.Text = b.id.ToString();
      txtTitle.Text = b.title;
      txtAuthor.Text = b.author;
      txtYear.Text = b.year.ToString();
      txtPublisher.Text = b.publisher;
      txtISBN.Text = b.isbn;
  }
  
  protected void btnDelete_Click(object sender, EventArgs e)
  {
  
      // Get the catalogue instance again (gone stale)
      Catalogue catalogueInstance = new Catalogue();
      // get the book id.
      ddlDelete.DataSource = catalogueInstance.books;
      // Get the book.
  
      Book b = catalogueInstance.books[ddlDelete.SelectedIndex - 1];
      txtID.Text = b.id.ToString();
      txtTitle.Text = b.title;
      txtAuthor.Text = b.author;
      txtYear.Text = b.year.ToString();
      txtPublisher.Text = b.publisher;
      txtISBN.Text = b.isbn;
  
      // Delete the book from catalogue instance
      catalogueInstance.books.RemoveAt(ddlDelete.SelectedIndex - 1);
  
      ddlDelete.SelectedIndex = 0;
  
      // serialise and write catalogue instance to file.
      catalogueInstance.books.RemoveAt(ddlDelete.SelectedIndex - 1);
  
      ddlDelete.SelectedIndex = 0;
  
      // rebind the ddl.
      ddlDelete.DataBind();
  
      int id = Int32.Parse(txtID.Text);
      Book book = catalogueInstance.books.SingleOrDefault(b =&gt; b.id == id);
      //catalogueInstance.books.Remove(book);
  
      catalogueInstance.books.RemoveAt(ddlDelete.SelectedIndex - 1);
  
      ddlDelete.SelectedIndex = 0;
  
  
      //ddlDelete_SelectedIndexChanged(ddlDelete, new EventArgs());
  
      if (book != null)
      {
  
          book.title = txtTitle.Text;
          book.year = Int32.Parse(txtYear.Text);
          book.author = txtAuthor.Text;
          book.publisher = txtPublisher.Text;
          book.isbn = txtISBN.Text;
  
          string jsonText = JsonConvert.SerializeObject(catalogueInstance);
          File.WriteAllText(FILENAME, jsonText);
      }
      txtSummary.Text = "Book ID of " + id + " has Been deleted from the 
  Catalogue" + Environment.NewLine;
  
      if (!catalogueInstance.books.Any())
      {
          txtSummary.Text = "There are no items in the Catalogue";
      }
  
  }
  }
  </code></pre>