Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Edit data in mvc entity framework database
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Shibly Sadik
9y
616
1
Reply
I have created a database using mvc CRUD operation.My edit action is as below:
// GET: /Student/Edit/5
public ActionResult Edit(
int id
)
{
if (
id
== null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
MyStudent mystudent = db.mdb.Find(
id
);
if (mystudent == null)
{
return HttpNotFound();
}
return View(mystudent);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include="Roll,Name,Dept,Gender,Phone")] MyStudent mystudent)
{
if (ModelState.IsValid)
{
db.Entry(mystudent).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(mystudent);
}
Now what i want to is to take the value of the parameter
id
through a textbox from user and perform the edition.
I'm very beginner. Help me please..
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to solve The operation has timed out during fetching
Change image