zoukankan      html  css  js  c++  java
  • asp.net dropdownlist和listbox

    if (!IsPostBack) 
            {
                //页面初次加载时执行这里的内容
                DataSet ds = new DataSet(); //数据集
                ds.Tables.Add("stu");
                ds.Tables["stu"].Columns.Add("id",typeof(int));
                ds.Tables["stu"].Columns.Add("name", typeof(string));
                ds.Tables["stu"].Columns.Add("score", typeof(int));
                ds.Tables["stu"].Rows.Add(new object[] { 1, "张三", 100 });
                ds.Tables["stu"].Rows.Add(new object[] { 2, "李四", 100 });
                ds.Tables["stu"].Rows.Add(new object[] { 3, "周五", 100 });
                ds.Tables["stu"].Rows.Add(new object[] { 4, "郑六", 100 });
                ds.Tables["stu"].Rows.Add(new object[] { 5, "甲七", 100 });
                this.ListBox1.DataSource = ds.Tables["stu"];
                this.ListBox1.DataTextField = "name"; //列表显示的字段
                this.ListBox1.DataValueField = "id";
                this.ListBox1.DataBind();
    
                //this.ListBox1.SelectedIndex  选中项的索引
                //this.ListBox1.SelectedItem   选中项
                //this.ListBox1.SelectedItem.Text   选中项的内容
                //this.ListBox1.SelectedItem.Value;  选中项的值
                //this.ListBox1.SelectedValue     选中项的值
            
                
            }
    

      

  • 相关阅读:
    python
    图片放大,缩小等操作
    template-web.js 自定义过滤器
    python
    python
    Android Volley源码分析及扩展
    Android 6.0动态权限申请教程
    Jarsigner签名使用
    Python正则表达式(总)
    Python错误和异常概念(总)
  • 原文地址:https://www.cnblogs.com/mengluo/p/5976094.html
Copyright © 2011-2022 走看看