/*************************************************************************
 *
 *                          GUI update methods
 *
 * ***********************************************************************/
 protected void ClearAllGridviews()
 {
     RecipeGridView.DataSource = null;
     RecipeGridView.DataBind();
     IngredientGridView.DataSource = null;
     IngredientGridView.DataBind();
     CategoryGridView.DataSource = null;
     CategoryGridView.DataBind();
     ContextGridView.DataSource = null;
     ContextGridView.DataBind();
     ltInstructions.Text = "Please select recipe to view recipe details.";
     Gv_imgs.DataSource  = null;
     Gv_imgs.DataBind();
 }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string[]        ImagePaths = Directory.GetFiles(Server.MapPath("~/Images/"));
         List <ListItem> Imgs       = new List <ListItem>();
         foreach (string imgPath in ImagePaths)
         {
             string ImgName = Path.GetFileName(imgPath);
             Imgs.Add(new ListItem(ImgName, "~/Images/" + ImgName));
         }
         Gv_imgs.DataSource = Imgs;
         Gv_imgs.DataBind();
     }
 }
        protected void UpdateReceipeDetailsGridViews(int recipeId)
        {
            using (Models.PlanMyDinnerDbContext database = new Models.PlanMyDinnerDbContext())
            {
                IngredientGridView.DataSource = database.Recipes.Find(recipeId).Ingredients.ToList();
                IngredientGridView.DataBind();

                CategoryGridView.DataSource = database.Recipes.Find(recipeId).Categories.ToList();
                CategoryGridView.DataBind();

                ContextGridView.DataSource = database.Recipes.Find(recipeId).Contexts.ToList();
                ContextGridView.DataBind();

                ltInstructions.Text = addHtmlBreakTags(database.Recipes.Find(recipeId).Instructions);

                string          CurrentDir = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName;
                string          ImagePath  = System.IO.Path.Combine(CurrentDir, "Media/" + database.Recipes.Find(recipeId).ThumbFileName);
                List <ListItem> Imgs       = new List <ListItem>();
                string          ImgName    = Path.GetFileName(ImagePath);
                Imgs.Add(new ListItem(ImgName, "~/Media/" + ImgName));
                Gv_imgs.DataSource = Imgs;
                Gv_imgs.DataBind();
            }
        }