mvc2中的二级联动(非用户控件)
<div id="cnblogs_post_body">我要达到的效果是在前面的下拉列表中选择机构,在后面的下拉列表中出现对应的部门。在部门表Dept中包含OrgID,但不是外键。在mvc中一般不设有外键。helper中代码:
<div class="cnblogs_code"> /// <summary> /// 根据机构id读取部门 /// </summary> /// <param name="id"></param> /// <returns></returns> public IList<Dept> GetDeptByOrgID(int id) { using (UUMContext uc = new UUMContext()) { var dept = from a in uc.Depts select a; if (id >= 0) { dept = dept.Where(a => a.OrgID == id); } IList<Dept> d = dept.ToList<Dept>(); return d; } }
页:
[1]