IEnumerable<SelectListItem> ColumnList = from a
in
Company.Column.ToList()
where a.parentID==0
select
new
SelectListItem
{
Value = a.ColumnID.ToString(),
Text = a.name
};
List<SelectListItem> Items =
new
List<SelectListItem>();
Items.Add(
new
SelectListItem { Value =
"0"
, Text =
"一级栏目"
});
Items.AddRange(ColumnList);
ViewBag.ColumnList = Items;
。。。。
添加静态数据项:
@Html.DropDownListFor(model => model.GroupCategoryID,new SelectListItem[] { new SelectListItem { Text = "小学", Value = "1" }, new SelectListItem { Text = "中学", Value = "2" } })
5.在页面中输出javascript变量值:
<script language="JavaScript" type="text/javascript">
var teacher = @Html.Raw(HttpUtility.HtmlDecode(teacherStr.ToString()));
请发表评论