日期:2014-05-17  浏览次数:20461 次

读取dataset的值,怎么绑定
从第二行开始读ds的数据,读完后怎么绑定到GridView
DataSet ds = new DataSet();
  objAdapter1.Fill(ds,"dt");
  for (int i = 1; i < ds.Tables["dt"].Rows.Count; i++)
  {
  string 序号 = ds.Tables["dt"].Rows[i][0].ToString();
  string 姓名 = ds.Tables["dt"].Rows[i][0].ToString();
  string 身份证号 = ds.Tables["dt"].Rows[i][0].ToString();
  string 性别 = ds.Tables["dt"].Rows[i][0].ToString();
  string 工作单位 = ds.Tables["dt"].Rows[i][0].ToString();
  string 联系电话 = ds.Tables["dt"].Rows[i][0].ToString();
  string 报考单位 = ds.Tables["dt"].Rows[i][0].ToString();
  string 报考岗位 = ds.Tables["dt"].Rows[i][0].ToString();
  string 准考证号 = ds.Tables["dt"].Rows[i][0].ToString();
  string 成绩 = ds.Tables["dt"].Rows[i][0].ToString();
  string 名次 = ds.Tables["dt"].Rows[i][0].ToString();
  }
  GridView1.DataSource =?;//读完的数据怎么绑定
  GridView1.DataBind();

------解决方案--------------------
GridView1.DataSource =ds.Tables["dt"];//读完的数据怎么绑定
GridView1.DataBind();
------解决方案--------------------
GridView1.DataSource= ds.Tables["dt"];
------解决方案--------------------
循环有必要么?直接绑定

GridView1.DataSource= ds.Tables["dt"];
GridView1.DataBind();
------解决方案--------------------
探讨

GridView1.DataSource =ds.Tables["dt"];//读完的数据怎么绑定
GridView1.DataBind();