コード例 #1
0
 protected void grvProperty_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         DropDownList DropDownType = (e.Row.FindControl("ddlType") as DropDownList);
         if (DropDownType == null)
         {
             DropDownType = (e.Row.FindControl("DropDownList2") as DropDownList);
         }
         DropDownType.DataSource     = _typeDal.GetAll();
         DropDownType.DataTextField  = "Name";
         DropDownType.DataValueField = "TypeId";
         DropDownType.DataBind();
         DropDownType.Items.Insert(0, new ListItem("--Select Qualification--", "0"));
         DataRowView dr = (DataRowView)e.Row.DataItem;
         DropDownType.Items.FindByValue(dr["TypeId"].ToString()).Selected = true;
     }
     else if (e.Row.RowType == DataControlRowType.Footer)
     {
         DropDownList DropDownType = (e.Row.FindControl("DropDownList1") as DropDownList);
         DropDownType.DataSource     = _typeDal.GetAll();
         DropDownType.DataTextField  = "Name";
         DropDownType.DataValueField = "TypeId";
         DropDownType.DataBind();
         DropDownType.Items.Insert(0, new ListItem("--Select Qualification--", "0"));
     }
 }
コード例 #2
0
ファイル: Login.cs プロジェクト: 1138631642/SCMS
        private void Login_Load(object sender, EventArgs e)
        {
            txtMsg.Hide();

            //加载所有用户的类型
            TypeDal   types = new TypeDal();
            DataTable dt    = types.GetAll();

            foreach (DataRow row in dt.Rows)
            {
                int    typeId = Convert.ToInt32(row["id"]);
                string type   = row["name"].ToString();
                cmbList.Items.Add(type);
            }
            //让第一项被选中
            cmbList.SelectedIndex = 0;
        }
コード例 #3
0
        private void AddUser_Load(object sender, EventArgs e)
        {
            //加载类型
            TypeDal   types = new TypeDal();
            DataTable dt    = types.GetAll();

            if (dt.Rows.Count <= 0)
            {
                MessageBox.Show("还没有添加用户.....");
                return;
            }
            foreach (DataRow row in dt.Rows)
            {
                comboBox2.Items.Add(row["name"]);
            }

            comboBox2.SelectedIndex = 0;
        }