Sabab Zulfiker

Sabab Zulfiker

  • NA
  • 85
  • 24.7k

Fetching data into checkboxes without using Html Helper

Mar 15 2018 1:04 AM
I have a language table in database, which contains language id and language name. The language table class is like below:
public partial class tblLanguage
{
public int colLanguageId { get; set; }
public string colLanguageName { get; set; }
public string colLanguageShortName { get; set; }
public Nullable colSerialNo { get; set; }
}
I am retrieving the language from database and pass them to the view and bind them with checkboxes, without using html helper method.
My controller code is below:
[HttpGet]
public ActionResult Save()
{
var languageList = db.tblLanguages.ToList();
ViewBag.Language = languageList;
return View();
}
And the code of the view is :
@{
ViewBag.Title = "Save";
Layout = "~/Views/Shared/_Layout.cshtml";
List languageList = ViewBag.Language;
}
@foreach (var languageItem in languageList)
{
@languageItem.colLanguageName
}
My question is how can I pass the checked values of the checkboxes to controller after performing POST operation.
N.B. I should not use HTML Helper or Html BeginForm().

Answers (1)