Want to build the ChatGPT based Apps? Start here
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Shibly Sadik
1.9k
165
125.3k
Edit data in mvc entity framework database
Feb 27 2015 10:52 AM
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..
Reply
Answers (
1
)
grid in mvc
Change image