I have page , where i can Edit User's Email and Password not problem ,but there is problem, when its send Data to Database , it will add new row everytime , when i just trying to edit User's Email, so how can i avoid that to not add new row in database , just send data in same row with out adding new row.
The code i have in my Action:
- public ActionResult UserEdit(string Email)
- {
- return View(new user {Email = Email });
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult UserEdit(user User)
- {
- var db = new DataContext();
- var u = db.PX.Where(t => t.Email_ID == User.Email).FirstOrDefault();
- if (u == null)
- db.PX.Add(new A_S_PX { Email_ID = User.Email, PS = User.Password });
- else {
- u.PS = User.Password;
- u.Email_ID = User.Email;
- }
- db.SaveChanges();
- return View(new user { Email = User.Email });
- }
10 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Man DownPosted Feb 2, 2018, 8:28 AM
Rupesh KahanePosted Feb 2, 2018, 8:19 AM
Other reference
Man DownPosted Feb 2, 2018, 8:08 AM
Rupesh KahanePosted Feb 2, 2018, 8:05 AM
Thanks
Man DownPosted Feb 2, 2018, 8:01 AM
Man DownPosted Feb 2, 2018, 7:40 AM
Nitin SontakkePosted Feb 2, 2018, 7:40 AM
Man DownPosted Feb 2, 2018, 7:34 AM
Rupesh KahanePosted Feb 2, 2018, 7:24 AM