zoukankan      html  css  js  c++  java
  • DropDownList 绑定

    绑定

                OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + Server.MapPath(".\\App_Data\\mydatabase.mdb"));
                string Sql = "SELECT * FROM Class ORDER BY Taxis,Id DESC";
                OleDbDataAdapter cmd = new OleDbDataAdapter(Sql, conn);
    
                DataSet ds = new DataSet();
                cmd.Fill(ds,"Class");
                this.DropDownList1.DataSource = ds.Tables["Class"].DefaultView;
    
                DropDownList1.DataTextField = "Name";//绑定显示名称的字段
                DropDownList1.DataValueField = "Id";//绑定值的字段
                DropDownList1.DataBind();
    


    添加

    for (int i = 1; i <=3; i++)
    {
        LIstItem li = new ListItem("文字" + i, "值" + i); //ListItem 代表列表的一项
        DropDownList.Items.Add(li); //Items属性维护了列表的项集合
    }
    

    获取选择项的Text,使用DropDownList.SelectedItem.Text
    获取选择项的Value,使用DropDownList.SelectedItem.Value
                        或者 DropDownList.SelectedValue
    

  • 相关阅读:
    thinkphp url生成
    thinkphp url大小写
    thinkphp 伪静态
    thinkphp action参数绑定
    thinkphp 前置和后置操作
    thinkphp 控制器定义
    thingkphp 路由实例
    thinkphp 闭包支持
    thinkphp 静态路由
    thinkphp 正则路由
  • 原文地址:https://www.cnblogs.com/hulang/p/1920636.html
Copyright © 2011-2022 走看看