• 数据绑定到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();
  • 相关阅读:
    Part 1R 函数、极限和连续
    Part 1 函数、极限与连续
    C++继承与派生
    VUE笔记
    VUE错误记录
    VUE笔记
    VUE笔记
    VUE笔记
    JS学习笔记
    Node.js笔记 请求方式 GET
  • 原文地址:https://www.cnblogs.com/wanghaibin/p/3872217.html
Copyright © 2020-2023  润新知