コード例 #1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            int     Customer_Id = int.Parse(Session["Customer_Id"].ToString());
            string  name        = Name.Text;
            string  password    = Password.Text;
            string  email       = Email.Text;
            decimal phone_no    = Decimal.Parse(Phone_No.Text);

            using (projectEntities1 context = new projectEntities1())
            {
                Customer_Info customer = context.Customer_Info.FirstOrDefault(s => s.Customer_Id == Customer_Id);
                customer.Customer_Password = password;
                customer.Email             = email;
                customer.Phone_No          = phone_no;
                context.SaveChanges();
            }
        }
コード例 #2
0
        protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            int Customer_Id = int.Parse(Session["Customer_Id"].ToString());

            for (int i = 0; i < e.NewValues.Count; i++)
            {
                if (e.NewValues[i] != null)
                {
                    e.NewValues[i] = Server.HtmlEncode(e.NewValues[i].ToString());
                }
            }
            using (projectEntities1 context = new projectEntities1())
            {
                Customer_Info customer = context.Customer_Info.FirstOrDefault(i => i.Customer_Id == Customer_Id);

                customer.Customer_Name     = e.NewValues[0].ToString();
                customer.Customer_Password = e.NewValues[1].ToString();
                customer.Email             = e.NewValues[2].ToString();
                customer.Phone_No          = Convert.ToDecimal(e.NewValues[3].ToString());

                context.SaveChanges();
            }
        }