//Controller code
PublicActionResult vote (intId=1) { //int id = 1;List NewList =db.lists.Find (ID); //var q = from P in db.lists where p.id==1 select P; //list NewList = new List {id=q.id}; //var tes = q; returnView (newlist); } [HttpPost] PublicActionResult vote (list newlist) {//var q = request.form["Item.id"]; //var p = Convert.ToInt32 (response.cookies["id"). Value);Al Newal =NewAl {uid = Convert.ToInt32 (request.cookies["ID"]. Value), lid = newlist.id, result = request.form["result"] }; DB.ALS.ADD (Newal); Db. SaveChanges (); intA = Newlist.id +1; List Next=Db.lists.Find (a); returnRedirecttoaction ("vote",New{id =A}); }
Trying to code
@model votesys.list@{viewbag.title="vote";}@using (Html.BeginForm ()) {@Html. AntiForgeryToken () @Html. ValidationSummary (true) <fieldset> <legend>list</legend>@Html. Hiddenfor (Model=model.id)<divclass="Editor-label">@Html. Labelfor (Model=model.question)</div> <divclass="Editor-field">@Html. Editorfor (Model=model.question) @Html. Validationmessagefor (Model=model.question)</div> <divclass="Editor-label">@Html. Labelfor (Model=Model.remark)</div> <divclass="Editor-field">@Html. Editorfor (Model=Model.remark) @Html. Validationmessagefor (Model=Model.remark)</div> <div> <input type="Radio"Id="Genderm"Name="result"Value="The company system is perfect"/>Option One<input type="Radio"Id="Genderf"Name="result"Value="reasonable distribution of personnel" checked/>option two</div> <p> <input type="Submit"Value="Save"/> </p> </fieldset>}<div>@Html. ActionLink ("Back to List","Index")</div>@section Scripts {@Scripts. Render ("~/bundles/jqueryval")}
MVC the same page loops through the database record (answer/voting system)