private void DGrdSubDept_DataBind() { int iDeptCode = Convert.ToInt32(this.HdnDeptCode.Value.ToString().Trim()); DeptManageDb deptManageDb = new DeptManageDb(); DataTable subDepartment = deptManageDb.GetSubDepartment(iDeptCode); this.DGrdSubDept.DataSource = subDepartment.DefaultView; this.DGrdSubDept.DataBind(); }
private void ReCreateDeptList(int iDeptID, string flag) { DeptManageDb deptManageDb = new DeptManageDb(); DataTable dataTable = new DataTable(); if (flag == "parent") { dataTable = deptManageDb.GetAllParentLevelDept(iDeptID); } else { if (flag == "children") { dataTable = deptManageDb.GetSubDepartment(iDeptID); } } if (dataTable.Rows.Count > 0) { this.ddlDept.Items.Clear(); ListItem item = new ListItem("返回上一级", dataTable.Rows[0]["i_sjdm"].ToString()); this.ddlDept.DataSource = dataTable; this.ddlDept.DataTextField = "v_bmmc"; this.ddlDept.DataValueField = "i_bmdm"; this.ddlDept.DataBind(); if (flag == "parent") { this.ddlDept.SelectedValue = Convert.ToString(iDeptID); } else { this.ddlDept.Items[0].Selected = true; iDeptID = Convert.ToInt32(this.ddlDept.Items[0].Value); } if (Convert.ToInt32(dataTable.Rows[0]["i_sjdm"].ToString()) != 0) { this.ddlDept.Items.Insert(dataTable.Rows.Count, item); } } }