Click here to Skip to main content
15,065,644 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hy Dear
Am already work on with .now i want to use with MVC
but dont know how to pass value html controls to controller on button click even
and what is entity framework am stuck in what is code first, model first or db first in entity framework

What I have tried:

How to insert data with in mvc with html controls
Updated 25-Apr-17 0:13am
F-ES Sitecore 20-Jan-17 4:39am
Passing data from view to controllers etc is basic MVC 101. We can't teach you a new technology from scratch over a "Quick Answer" forum post. Get a book on MVC and go through it to learn the basics, or at least go through some on-line tutorials, eg google "mvc book store"
Hemant Singh Rautela 20-Jan-17 5:36am
"What I have tried: "
Did you try something ? I don't think so. You have to read from start & you can see online video-tutorial. there are many available for basic, & you can search CRUD operation in MVC...

1 solution

For Insert Record From View to Controller use this code to your Controller

private SqlConnection con;
//To Handle connection related activities
private void connection()
string constr = ConfigurationManager.ConnectionStrings["getconn"].ToString();
con = new SqlConnection(constr);

//To Add Employee details
public bool AddEmployee(EmpModel obj)

SqlCommand com = new SqlCommand("AddNewEmpDetails", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Name", obj.Name);
com.Parameters.AddWithValue("@City", obj.City);
com.Parameters.AddWithValue("@Address", obj.Address);

int i = com.ExecuteNonQuery();
if (i >= 1)

return true;


return false;


and SP Code is From SQL Side
Create procedure [dbo].[AddNewEmpDetails]
@Name varchar (50),
@City varchar (50),
@Address varchar (50)
Insert into Employee values(@Name,@City,@Address)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900