示例#1
0
 public void Initialize_Page()
 {
     Sub_Account                  = new SubAccount();
     ToDateTxt.Text               = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
     Dropdownlist1.DataSource     = db.MainAccount.ToList();// mainaccount.GetAllMain();
     Dropdownlist1.DataTextField  = "name";
     Dropdownlist1.DataValueField = "ID";
     Dropdownlist1.DataBind();
     FillDrops();
 }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DataTable table = d.GetDonors();
         Dropdownlist1.DataSource     = table;
         Dropdownlist1.DataTextField  = "PersonLastName";
         Dropdownlist1.DataValueField = "PersonKey";
         Dropdownlist1.DataBind();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection sc = new SqlConnection(@"Data Source=ASAD-PC;Initial Catalog=student;Integrated Security=True");

            sc.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select * from tbl_student", sc);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            Dropdownlist1.DataSource     = dt;
            Dropdownlist1.DataTextField  = "std_id_pk";
            Dropdownlist1.DataValueField = "std_name";
            Dropdownlist1.DataBind();
            sc.Close();

            Response.Write(Dropdownlist1.SelectedItem);
            Response.Write(Dropdownlist1.SelectedValue);
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //SqlConnection con = new SqlConnection(@"Data Source=CYBORG\INSTANCE1;Initial catalog=Gestion de Services;Integrated Security=true");

            if (!IsPostBack)
            {
                cn.con.Open();

                SqlCommand     com = new SqlCommand("select * from Metiers", cn.con);
                SqlDataAdapter da  = new SqlDataAdapter(com);
                DataSet        ds  = new DataSet();
                da.Fill(ds);                                                                  // fill dataset
                Dropdownlist1.DataTextField  = ds.Tables[0].Columns["nom_metier"].ToString(); // text field name of table dispalyed in dropdown
                Dropdownlist1.DataValueField = ds.Tables[0].Columns["ID_metier"].ToString();  // to retrive specific  textfield name
                Dropdownlist1.DataSource     = ds.Tables[0];                                  //assigning datasource to the dropdownlist
                Dropdownlist1.DataBind();                                                     //binding dropdownlist
                cn.con.Close();
            }
        }