protected void grdCategories_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //identify the CategoryID from the row that we want to delete
            Int32 CategoryID = Convert.ToInt32(grdCategories.DataKeys[e.RowIndex].Values["CategoryID"]);

            //connect
            using (DefaultConnection db = new DefaultConnection())
            {
                //same as sql command (SELECT * categories WHERE CategoryID= the variable)
                //select current category into memory based on the ID
                Category objC = (from c in db.Categories
                                 where c.CategoryID == CategoryID
                                 select c).FirstOrDefault();

                //delete
                db.Categories.Remove(objC);
                    db.SaveChanges();

                //refresh the grid
                    GetCategories();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //connect to database
            using (DefaultConnection db = new DefaultConnection())
            {
                //create a new category in memory
                Category objC = new Category();

                //Int32 CategoryID = 0;

                //try to find the url
                if (!string.IsNullOrEmpty(Request.QueryString["CategoryID"]))
                {
                    //get the ID
                    Int32 CategoryID = Convert.ToInt32(Request.QueryString["CategoryID"]);

                    //see which category it is
                    objC = (from c in db.Categories
                            where c.CategoryID == CategoryID
                            select c).FirstOrDefault();
                }

                //fill the properties of the new category we are adding
                objC.CategoryName = txtName.Text;

                //add it if there is no id found call the add function
                if (String.IsNullOrEmpty(Request.QueryString["CategoryID"]))
                {
                   db.Categories.Add(objC);
                }

                //save the new category
                db.SaveChanges();

                //redirect to the categories list page
                Response.Redirect("categories.aspx");
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //connect to database
            using (DefaultConnection db = new DefaultConnection())
            {
                //create a new recipe in the memory
                Recipe objR = new Recipe();

                //check for the url
                if (!string.IsNullOrEmpty(Request.QueryString["RecipeID"]))
                {
                    //get the ID
                    Int32 RecipeID = Convert.ToInt32(Request.QueryString["RecipeID"]);

                    //check recipe
                    objR = (from r in db.Recipes
                            where r.RecipeID == RecipeID
                            select r).FirstOrDefault();
                }

                //fill the properties of the new recipe
                objR.RecipeName = txtName.Text;

                //add it - if no id found call the add function
                if (String.IsNullOrEmpty(Request.QueryString["RecipeID"]))
                {
                   db.Recipes.Add(objR);
                }

                //save new recipe on db
                db.SaveChanges();

                //redirect user to the recipes page
                Response.Redirect("recipes.aspx");
            }
        }