怎么实现GridView行绑定

来源:百度知道 编辑:UC知道 时间:2024/05/14 19:51:15

DataSet ds=new DataSet();
this.GridView.DataSource=ds;//数据集
this.GridView.DataMember="tb1";//哪张表
this.GridView.DataValueField="id";//绑定字段
this.GridView.DataTextField="name";//要显示的字段
this.GridView.DataBind();//刷新数据

conn = new SqlConnection(strconn);
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
this.GridView.DataSource=ds;
this.GridView.DataBind();
以上的就可以绑定数据了.但是如果这里面有不想显示的数据列的话,就要在GridView的属性中的编辑列中进行修改...