private string GetWorksTypeName(int typeID) { WorksType dr = DAL.WorksType.GetWorksTypeByID(typeID); if (dr != null) { return(dr.WorksTypeName); } else { return(""); } }
/// <summary> /// 获取带有级别的数据集 /// </summary> /// <returns></returns> private void GetWorksTypeByLevel(ref List <WorksType> dsResult, List <WorksType> dsWorksType, int parentID, int level) { List <WorksType> drs = dsWorksType.Where(p => p.ParentID == parentID).ToList(); foreach (WorksType dr in drs) { WorksType drTmp = new WorksType(); drTmp.WorksTypeID = dr.WorksTypeID; int len = dr.WorksTypeName.Length; drTmp.WorksTypeName = dr.WorksTypeName.PadLeft(len + level * 6, '-'); dsResult.Add(drTmp); GetWorksTypeByLevel(ref dsResult, dsWorksType, dr.WorksTypeID, level + 1); } }
/// <summary> /// 初始化控件 /// </summary> private void InitControl() { ////学校 //List<CSSchoolWorksNum > dsSchool = DAL.User.GetSchoolWorksNum(DAL.Common.ContestID(Page) ); //List<CSSchoolWorksNum > dsTmp = new List<CSSchoolWorksNum >(); //CSSchoolWorksNum dr = new CSSchoolWorksNum (); //dr.SchoolID = 0; //dr.SchoolName = "全部"; //dsTmp.Add(dr); //dsTmp.AddRange (dsSchool); //dsSchool = dsTmp.ToList (); //ddlSchool.DataSource = dsSchool; //ddlSchool.DataTextField = "SchoolName"; //ddlSchool.DataValueField = "SchoolID"; //ddlSchool.DataBind(); //作品分类 List <WorksType> dsWorksType1 = GetDSWorksType; List <WorksType> dsWorksType = new List <WorksType>(); GetWorksTypeByLevel(ref dsWorksType, dsWorksType1, 0, 0); List <WorksType> efdsTmp = new List <WorksType>(); WorksType efdr = new WorksType(); efdr.WorksTypeID = 0; efdr.WorksTypeName = "全部"; efdsTmp.Add(efdr); efdsTmp.AddRange(dsWorksType); dsWorksType = efdsTmp.ToList(); ddlWorksType.DataSource = dsWorksType; ddlWorksType.DataTextField = "WorksTypeName"; ddlWorksType.DataValueField = "WorksTypeID"; ddlWorksType.DataBind(); //专家 List <CSUserWithSchoolAndRole> dsExpert = GetDSExperts; List <CSExpertWorksTypeDetail> dsExpertWorksType = GetDSExpertWorksType; foreach (CSUserWithSchoolAndRole drExprt in dsExpert) { string worksType = ""; List <CSExpertWorksTypeDetail> drs = dsExpertWorksType.Where(p => p.UserID == drExprt.UserID).ToList(); if (drs.Count > 0) { worksType = drs[0].WorksTypeName; } drExprt.WorksType = worksType; } gvExpert.DataSource = dsExpert; gvExpert.DataBind(); }
private void InitControl() { //作品分类 List <WorksType> dsWorksType1 = GetDSWorksType; List <WorksType> dsWorksType = new List <WorksType>(); WorksPartition.GetWorksTypeByLevel(ref dsWorksType, dsWorksType1, 0, 0); List <WorksType> dsTmp = new List <WorksType>(); WorksType dr = new WorksType(); dr.WorksTypeID = 0; dr.WorksTypeName = "全部"; dsTmp.Add(dr); dsTmp.AddRange(dsWorksType); dsWorksType = dsTmp.ToList(); ddlWorksType.DataSource = dsWorksType; ddlWorksType.DataTextField = "WorksTypeName"; ddlWorksType.DataValueField = "WorksTypeID"; ddlWorksType.DataBind(); }