• 数据绑定到ADO.NET


    // Define a DataSet with a single DataTable.
    DataSet dsInternal = new DataSet();
    dsInternal.Tables.Add("Users");
      
    // Define two columns for this table.
    dsInternal.Tables["Users"].Columns.Add("Name");
    dsInternal.Tables["Users"].Columns.Add("Country");
      
    // Add some actual information into the table.
    DataRow rowNew = dsInternal.Tables["Users"].NewRow();
    rowNew["Name"] = "John";
    rowNew["Country"] = "Uganda";
    dsInternal.Tables["Users"].Rows.Add(rowNew);
      
    rowNew = dsInternal.Tables["Users"].NewRow();
    rowNew["Name"] = "Samantha";
    rowNew["Country"] = "Belgium";
    dsInternal.Tables["Users"].Rows.Add(rowNew);
      
    rowNew = dsInternal.Tables["Users"].NewRow();
    rowNew["Name"] = "Rico";
    rowNew["Country"] = "Japan";
    dsInternal.Tables["Users"].Rows.Add(rowNew);
    
    // Define the binding.
    lstUser.DataSource = dsInternal.Tables["Users"];
    lstUser.DataTextField = "Name";
    //或者
    
    // Define the binding.
    lstUser.DataSource = dsInternal;
    lstUser.DataMember = "Users";
    lstUser.DataTextField = "Name";
    //
    this.DataBind();
  • 相关阅读:
    PHP—字符串编码
    使用html模板
    创建html模板
    默认.htpl改为.htpl
    eclipse导入项目前面有感叹号
    eclipse点不出方法
    eclipse界面混乱
    面试题
    多线程
    瀑布流
  • 原文地址:https://www.cnblogs.com/wanghaibin/p/3872217.html
Copyright © 2020-2023  润新知