TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Man Down
NA
48
3.5k
How to avoid to not add new row in DB , When i Edit User's
Feb 2 2018 6:59 AM
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 });
}
Reply
Answers (
10
)
How to find id using hiddenfield in gridview on button click
i need to take input from G-maps and show that in a label.