protected void Delete_Click(object sender, EventArgs e)
        {
            GridViewRow row        = ((Button)sender).Parent.Parent as GridViewRow;
            var         categoryId = int.Parse(CategoriesGrid.DataKeys[row.RowIndex].Value.ToString());

            LibrarySystemDbContext data = new LibrarySystemDbContext();
            var category = data.Categories.FirstOrDefault(x => x.Id == categoryId);

            CategoryDelete.DataSource = new List <Category> {
                category
            };
            CategoryDelete.DataBind();
        }
        protected void SaveDelete_Click(object sender, EventArgs e)
        {
            var id = int.Parse(CategoryDelete.DataKey.Value.ToString());

            LibrarySystemDbContext data = new LibrarySystemDbContext();
            var category = data.Categories.FirstOrDefault(x => x.Id == id);

            data.Books.RemoveRange(category.Books);
            data.Categories.Remove(category);

            data.SaveChanges();

            CategoryDelete.DataSource = null;
            CategoryDelete.DataBind();
            CategoriesGrid.DataBind();
        }
 protected void CancelDelete_Click(object sender, EventArgs e)
 {
     CategoryDelete.DataSource = null;
     CategoryDelete.DataBind();
 }