示例#1
0
        protected void BuildEmployeesMenu()
        {
            Database data = new Database();
            SqlDataReader reader = data.GetSubordinates(User.EmployeeID, ForecastMonth, Convert.ToBoolean(lstStatus.SelectedValue));
            if (reader.HasRows)
            {
                lstEmployees.DataSource = reader;
                lstEmployees.DataTextField="EmployeeName";
                lstEmployees.DataValueField="intEmployeeID";
                lstEmployees.DataBind();
            }
            else
            {
                lstEmployees.Items.Clear();
            }
            if (lstEmployees.Items.Count > 0)
            {
                if((EmployeeID > 0)&&(lstEmployees.Items.FindByValue(EmployeeID.ToString()) != null))
                {
                    lstEmployees.SelectedValue = EmployeeID.ToString();
                }
                else
                {
                    lstEmployees.SelectedIndex = 0;
                    EmployeeID = int.Parse(lstEmployees.SelectedValue);
                }

            }

            data.Close();
            data.Dispose();
        }