locked
c# - problem with linq to sql update using asp.net textboxes RRS feed

  • Question

  • hi, all. i have textboxes and every texbox has data. when i click button, datas dont change. please help me. thanks in advance!

    code behind...

    protected void Page_Load(object sender, EventArgs e)
    {
    Dictionary<string, string> dct = CUser.GetUserInfo();
    tbxFirstName.Text = dct["FirstName"];
    tbxLastName.Text = dct["LastName"];
    tbxEmail.Text = dct["Email"];
    tbxPhone.Text = dct["Phone"];
    tbxPassportNumber.Text = dct["PassportNumber"];
      tbxUsername.Text = dct["Username"];
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
    CUser cUser = new CUser();
    cUser.FirstName = tbxFirstName.Text;
    cUser.LastName = tbxLastName.Text;
    cUser.Phone = tbxPhone.Text;
    cUser.Email = tbxEmail.Text;
    cUser.Username = tbxUsername.Text;
    cUser.PassportNumber = tbxPassportNumber.Text;

    cUser.Attach();

    if (!cUser.Save())
    {

    }
      }

    this is my method...

    public void Attach (User user)
    {
    using (var db = new MiniFootballEntities())
    {
    db.Users.Attach(user);
    db.SaveChanges();
    }
    }

    Tuesday, October 29, 2013 7:08 PM