码迷,mamicode.com
首页 > Web开发 > 详细

数据绑定到ADO.NET

时间:2014-07-28 11:20:50      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   数据   io   for   div   ar   

// De?ne a DataSet with a single DataTable.
DataSet dsInternal = new DataSet();
dsInternal.Tables.Add("Users");
  
// De?ne 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);

// De?ne the binding.
lstUser.DataSource = dsInternal.Tables["Users"];
lstUser.DataTextField = "Name";
//或者

// De?ne the binding.
lstUser.DataSource = dsInternal;
lstUser.DataMember = "Users";
lstUser.DataTextField = "Name";
//
this.DataBind();

 

数据绑定到ADO.NET,布布扣,bubuko.com

数据绑定到ADO.NET

标签:style   blog   color   数据   io   for   div   ar   

原文地址:http://www.cnblogs.com/wanghaibin/p/3872217.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!