We help IT Professionals succeed at work.

MVC CRUD in VB.NET - Edit not saving

ttist25
ttist25 asked
on
Hello there,

I'm working on an MVC vb.net app and I'm trying to do my first CRUD implementation.  I've got the List and details pieces working fine but Edit is giving me some trouble.  I'm working from the tutorial here but it's in C# and i'm trying to convert it to VB.NET

Anyway, when I click the Edit link in my list view, it brings up the correct record and the correct information in the fields, but when I change it and click save I get oops.  

       <HttpPost> _
        Function Edit(ByVal id As Integer, ByVal collection As FormCollection) As ActionResult
            Try
                ' TODO: Add update logic here
                Dim v As People_t = db.People_ts.Single(Function(vh) vh.People_ID = id)

                v.LastName = Integer.Parse(collection("LastName"))

                v.FirstName = Integer.Parse(collection("FirstName"))

                v.Discipline_ID = Integer.Parse(collection("Discipline_ID"))

                db.SubmitChanges()

                Return RedirectToAction("Index")
            Catch
                Return View("oops")
            End Try
        End Function

Open in new window


Any ideas where I've gone wrong?

TIA!
Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2014
Commented:
>v.LastName = Integer.Parse(collection("LastName"))

Last name would not be an integer I guess. So change

v.LastName = collection("LastName")

v.FirstName = collection("FirstName")

Author

Commented:
You're the man.