@model JustDial.Models.tblCityMaster <table class="MainTable"> <tr> <td>@using (Html.BeginForm("Index", "City", FormMethod.Post)) { <table class="Mytable"> <tr> <td colspan="2"> @Html.LabelFor(model => model.City_Name) </td> </tr> <tr> <td colspan="2"> <div class="editor-field"> @Html.EditorFor(model => model.City_Name) @Html.ValidationMessageFor(model => model.City_Name) </div> </td> </tr> <tr> <td> <input type="submit" class="ButtonBlue" value="Create" /> </td> <td> </td> </tr> </table> } </td> </tr> </table>
public class CityController : Controller { JustDialEntities db = new Models.JustDialEntities(); // // GET: /City/ public ActionResult Index() { return View(db.tblCityMasters); } [HttpPost] public ActionResult Index(tblCityMaster objCity) { if (ModelState.IsValid) { db.tblCityMasters.AddObject(objCity); db.SaveChanges(); } return View(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)