@using(Html.BeginForm("submit","Security",FormMethod.Post)) { @foreach (var item in Model.app_function) { <input type="checkbox" name="Functioncheck" value="@item.app_function_id"/> @Html.Encode(item.app_function_name) } <input type="submit" value="submit" /> }
[AcceptVerbs(HttpVerbs.Post)] public ViewResult submit(FormCollection fm) { string Roleecheck = Request.Form["Functioncheck"].ToString(); string[] x = Roleecheck.Split(','); int a = Convert.ToInt32(x.Length); for (int i = 0; i < x.Length; i++) { int userid = Convert.ToInt32(x[i]); var myEntity = new user_role { role_id = id, user_id = userid, created_date = DateTime.Now, created_by = 1 }; UpdateModel(myEntity); am.Add(myEntity); } am.Save(); return view(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)