Click here to Skip to main content
15,886,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i am new in MVC

i want one form let say will insert City and same page will have grid will show all City

so how show i processed

i stuck in same page how can i implement grid IEnumerable
which will have delete select activity on same page

can any one help


HTML
@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>



C#
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();
       }

   }
Posted

1 solution

You can use Ajax.BeginForm for Add/Edit/Delete with different actionMethods and Partial View for Grid for one page application
 
Share this answer
 

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