Search Results

Search found 1 results on 1 pages for 'user1298215'.

Page 1/1 | 1 

  • How to save checkbox checked values in Database

    - by user1298215
    How to save checkbox values in database. Below is my view code. @foreach (var item in Model) { @Html.CheckBox("statecheck", (IEnumerable<SelectListItem>)ViewData["StatesList"]) @Html.DisplayFor(modelItem => item.state_name) </br> } <input class="ASPbutton" type="submit" value="submit"/> Below is My controller. public ActionResult States() { ViewData["StatesList"] = new SelectList(am.FindUpcomingStates().ToList(), "state_id", "state_Name"); return View(); } My model is public IQueryable<state> FindUpcomingStates() { return from state in Adm.states orderby state.state_name select state; } After clicking submit button checked item state_id will be saved into database. I wrote like below in Controller, but i got true or false values, i want state_id [AcceptVerbs(HttpVerbs.Post)] public ActionResult States(string _stateName, char[] statecheck, FormCollection formvalues) { statecheck = Request.Form["statecheck"].ToArray(); ViewData["StatesList"] = new SelectList(am.FindUpcomingStates222().ToList(), "state_id", "state_id", _stateName); }

    Read the article

1