hello,
i am using listbox to insert the value in database
on edit mode i want to assign the databsae value back to listbox how to assign it on page load the database value to listbox as selcted
for e.g list box populate
men
women
child
and in databsae the value for this item has gone as men so on page load men should be auto selected
<div class="col-md-3 padding5">
@Html.ListBoxFor(m => m.gender, Model.FirstLevel, new { @class = "form-control padding5", onchange = "SelectedIndexChanged()" })
</div>
CascadingModel model = new CascadingModel();
var firstlevelcategory = (from fc in db.categories
where (fc.title != "")
orderby fc.title
select new
{
gender = fc.gender
});
foreach (var fc in firstlevelcategory)
{
model.FirstLevel.Add(new SelectListItem { Text = fc.gender, Value = fc.gender.ToString() });
}
return View(model);