public ActionResult Edit(string id) { ViewBag.Perm = GetPermission(); Flow_FormModel model = m_BLL.GetById(id); //得到已经选择的字段 StringBuilder sb = new StringBuilder(); //获得对象的类型,model Type formType = model.GetType(); //查找名称为"A-Z"的属性 string[] arrStr = { "AttrA", "AttrB", "AttrC", "AttrD", "AttrE", "AttrF", "AttrG", "AttrH", "AttrI", "AttrJ", "AttrK" , "AttrL", "AttrM", "AttrN", "AttrO", "AttrP", "AttrQ", "AttrR", "AttrS", "AttrT", "AttrU" , "AttrV", "AttrW", "AttrX", "AttrY", "AttrZ" }; foreach (string str in arrStr) { object o = formType.GetProperty(str).GetValue(model, null); if (o != null) { //查找model类的Class对象的"str"属性的值 sb.Append(GetAttr(o.ToString(), str)); } } ViewBag.AttrList = sb.ToString(); List <Flow_TypeModel> list = typeBLL.GetList(ref setNoPagerAscBySort, ""); ViewBag.FlowType = new SelectList(list, "Id", "Name", model.TypeId); ViewBag.FlowTypeName = new SelectList(list, "Id", "Name"); return(View(model)); }