C# DataGridView控件绑定数据源的方式
2016-11-07 23:08
651 查看
注:
直接添加并绑定数据库,要删除的话,需(?)删除数据库中的数据,然后重新给DATAGRIDVIEW绑定数据源,使用
第一种:
第二种:
第三种:
第四种:
第五种:
第六种:
第七种:
第八种:
以后待阅读:
DataGridView控件—绑定数据方法
直接添加并绑定数据库,要删除的话,需(?)删除数据库中的数据,然后重新给DATAGRIDVIEW绑定数据源,使用
dataGridView.Row.Clear()无效。
第一种:
DataSet ds=new DataSet (); this.dataGridView1.DataSource=ds.Table[0];
第二种:
DataTable dt=new DataTable(); this.dataGridView1.DataSource=dt;
第三种:
DataSet ds=new DataSet (); this.dataGridView1.DataSource = ds.Tables["表名"];
第四种:
DataSet ds=new DataSet (); this.dataGridView1.DataSource = ds; this.dataGridView1.DataMember = "表名";
第五种:
ArrayList Al = new ArrayList(); this.dataGridView1.DataSource = Al;
第六种:
Dictionary<string, string> dic = new Dictionary<string, string>(); this.dataGridView1.DataSource = dic;
第七种:
DataView dv = new DataView(); this.dataGridView1.DataSource = dv;
第八种:
this.dataGridVi.DataSource = new BindingList<Object>(List<Object>);
以后待阅读:
DataGridView控件—绑定数据方法
相关文章推荐
- C#中DataGridView控件绑定控件绑定数据源方式
- C# DataGridView绑定数据源的几种常见方式
- .net中用界面绑定的方式实现控件联动
- 一个数据源赋给多个COMBOX控件绑定,改变一个COMBOX值时其它几个也跟着改变(已有解决方案)
- Repeater控件自定义数据源代码绑定实例
- Demo: Dictionary>> 泛型读取XML文件数据作为数据源(DataSource)绑定到DropDownList控件 定义个一个公用类
- ASP.Ne控件数据绑定一种方式
- 数据绑定技术—将 DataReader 做为数据源绑定到 DataGrid 控件
- 如何将XML作为数据源绑定到控件
- Chapter4:绑定控件到数据源
- 地磅称量系统之(37~39) 直接向数据库的数据表WtBill添加测试数据以及绑定用户控件和使用编码的方式控制dataGridView控件的每列属性和添加数据数据库的表中不存在的字段(非绑定列)
- 将 DataReader 做为数据源绑定到 DataGrid 控件
- infopath中界面控件和数据源的绑定
- 数据绑定控件把数据导入到EXCEL的实现方式
- ASP.NET 2.0 的数据源、数据绑定控件概述与区别
- ASP.NET 2.0的几种数据源和数据绑定控件
- 数据绑定服务器控件的 几种方式
- 如何让GridView控件在绑定的数据源没有数据时也显示标题
- ASP.NET基础教程-DataGrid表格控件-绑定数据源
- ASP.NET 2.0 中的几种数据源和数据绑定控件