예제 #1
0
        protected void btnProdEdit_Click(object sender, EventArgs e)
        {
            DataSet images = Methods.GetImages(Server.MapPath("~/Images/Products"));

            ddlImages.DataSource = images.Tables[0];

            ddlImages.DataValueField = "FileName";
            ddlImages.DataTextField  = "FileName";
            ddlImages.DataBind();
            plProductsView.Visible = false;
            plEditProduct.Visible  = true;
            Button      btn    = (Button)sender;
            GridViewRow gvr    = (GridViewRow)btn.NamingContainer;
            string      prodID = gvProducts.DataKeys[gvr.RowIndex].Values[0].ToString();

            for (int i = 1; i < 100; i++)
            {
                ListItem item = new ListItem();
                item.Text  = i.ToString();
                item.Value = i.ToString();
                ddlOrderIndex.Items.Add(item);
            }

            FileUpload2.Visible     = false;
            ddlImages.Visible       = true;
            imgSample.Visible       = true;
            plUpdatProdSucc.Visible = false;

            //Response.Write(Methods.GetImages(Server.MapPath("~/Images/Products")).Tables[0].Rows[1][1].ToString());
            GoodEatsFarmDataContext db = new GoodEatsFarmDataContext();
            var data = db.uspProductsGetSingle(prodID).FirstOrDefault();

            txtTitle2.Text = data.Name;
            txtPrice2.Text = data.PriceInfo;
            txtDesc2.Text  = data.Description;
            lblProdID.Text = data.ProductID.ToString();
            ddlOrderIndex.SelectedValue = data.OrderIndex.ToString();
            lblTest.Text             = "Originally was: " + data.Name;
            imgSample.ImageUrl       = data.ImagePath;
            chkbxImage.SelectedValue = "Use Existing Photo";
            ddlImages.SelectedValue  = Path.GetFileName(data.ImagePath);
            plNewProduct.Visible     = false;
        }