sarah2
سه شنبه 18 اردیبهشت 1397, 08:02 صبح
قصد دارم حدودا 20 تا Dropdown را در یک صفحه قرار بدهم, آیا به غیر از Viewbag راهی هست؟
RIG000
سه شنبه 18 اردیبهشت 1397, 10:26 صبح
مستقیم با مدل هم میتونی
public class Data
{
public List<tbl_Dept> lstDepatrment;
public List<tbl_employees> lstEmployee;
//other
@model MVCApp.Models.Data
@{
var categoryList = Model.lstDepatrment.Select(cl => new SelectListItem
{
Value = cl.Dept_ID.ToString(),
Text = cl.Dept_Description == null ? String.Empty : cl.Dept_Description
});
}
و در ویو
@(Html.DropDownList("sampleDropdown", categoryList, "-----Select-----"))
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.