Part 11- Insert data into database in ASP.NET MVC | Submit a Form and Save Record | HD Video

preview_player
Показать описание


SOCIAL :

GET CODE here :

INTRODUCTION :
Please follow the steps :

Step 1 : Use html.BeginForm and pass the method name ,controller name and form type .
Step 2: Put all elements inside html begin form .

Step 3: At Test controller create a method Save Record and pass EmployeeViewModel class as parameter.

Step 4 : When you submit a form then control goes to your given method name in html BeginForm ,so you can get all element data at that method parameter.

Step 5 : Create object of Employee class and and add properties value equals to the parameter properties value

Step 6 : Finally add this class to db context and call savechanges method .

Step 7 : you can get the latest id of employee .

So in this way you can insert data in database .Here we submit a form and save record in database using Entity framework.

RECOMMENDATION

I strongly suggest you to watch these videos in order to consolidate your knowledge .

Watch MODEL VIEW ,CONTROLLER and DATABASE Connection Video :

TAGS :
how to create a - website
asp. net mvc
asp .net mvc tutorial
asp. net mvc 4
asp net mvc developer
asp net mvc continuous integration
asp net mvc hosting
model view controller
jquery-ajax
$ ajax jquery
jquery ajax tutorial
viewbag
$controller
$model
razor view engine
$how to get rich
Рекомендации по теме
Комментарии
Автор

Lad, please, either pause your Avast during your videolectures or provide a dislaimer that this video may be harmful for people with heart problems (or they can get those at 6:51). I've lost a month of life at 6:51 and still have this bell ringing in my head.
Speaking about the lecture itself -- thanks a lot, well done. But a thrilling one :).

SergeyChaschin
Автор

This is just what I needed to get my confidence back..god bless you mate..do this with music in ur ears..works like a charm bro!!

seanpereira
Автор

Excellent tutorials, thus far. Thank you for taking the time to make these videos!

dafringe
Автор

Damn the noise ...I actually was watching this in 1am ...falling asleep...well, I am awake and scared hahaah

albasula
Автор

Thanks!... you helped me to solve an error!

numairazher
Автор

sir really perfect Tutorials thank you for that u r really big king :)))

ilkerdoner
Автор

I saw a lot of videos but this is really nice. 100 out of 100.
I have a request, please make the same page using MVC, Restfull web api and with the ajax call.

Rajesh-rgfw
Автор

It s very useful for me.i am expecting more videos like this. Thank you

veeramuthudotnetveera
Автор

Hey Ashish, Thanks a lot for Good Tutorial,
I'm Sory i have a little Problems, when i use try and catch code, its return me this Errors when i click submit.


Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
"


Can you give me some advice for this erros, i've been searching for the solutions and those solution wasnt works for me.

TheTallyhoviper
Автор

Thank you very much Ashish, this really help me alot.

marcinedoza
Автор

Excelente material, muchas gracias !!!

josereynelchauxperez
Автор

Thanks a lot.very informative and precise training approach.

olabodebowoto
Автор

When i go to my table definition it doesnt show the same class like yours it shows a partial class " public partial class ShippingDetails" is it okay to use it anyways?

heshammhawach
Автор

Please silent that avast notif. it almost kill me at 3 AM

By the way thanks, sooo useful

prayogamaturangga
Автор

hello sir,
all are goes right.till maka a form.
when i add @using(html.beginform("save", "controller", formmethod.post()).
it throws an error i.e: argument 3 cannot convert from anonymous type string class string placeholder to string.

abdulmubeen
Автор

Hey,


Could you explain to me what is MVC Tutorial Entities in the controller?

Pendyalakirit
Автор

Hi. When submit record i got this error

Violation of PRIMARY KEY constraint 'PK_Employee'. Cannot insert duplicate key in object 'dbo.Employee'. The duplicate key value is (0).

keanemgl
Автор

Thank you so much for your videos
I have a question, when i write part of "int latestEmpId = emp.EmployeeID;" i take error of dupplicate to primary key
what should i do?

mucahidakyar
Автор

wtf was that avast notification...scared the hell out of me

abdulmateen
Автор

sir when i try to save my record its done only one time...coz the id become zero then after it was been error when i was enter another data..the exception name is=DbupdateException was unhandled by user

yogeshsinghrawat
welcome to shbcf.ru