专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > LINQ

linq + GridView页面数据没有显示,该怎么处理

发布时间:2011-06-24 21:55:57 文章来源:www.iduyao.cn 采编人员:星星草
linq + GridView页面数据没有显示
protected void Page_Load(object sender, EventArgs e)
  {
  //Database db = new Database();
  //string sql = "select id,field_code from field_baseinfo";
  //FarmlandManageGridView.DataSource = db.GetReader(sql);
  //FarmlandManageGridView.DataBind();
  //db.Close();
  FreshGridViewWithData();

  }


  //刷新GridView
  private void GridViewDataBind()
  {
  FarmlandManageGridView.DataSource = buildDisplayTable();
  FarmlandManageGridView.DataBind();
  }

  private void FreshGridViewWithData()
  {
  long danwei_id = DataTypeUtil.ParseLong(this.unitDropDownList.SelectedValue.ToString());
  int theYear = DataTypeUtil.ParseInt(this.yearDropDownList.SelectedItem.ToString());
  selectedlist = service.FindByDanweiAndYear(danwei_id, theYear);
  GridViewDataBind();
  }

  private DataTable buildDisplayTable()
  {
  var result = selectedlist.Select(p => new
  {
  id = p.id,
  field_code = p.crop_manageinfo.field_baseInfo.field_code,
  cropname = p.crop_manageinfo.breeds.crop.cropname,
  breed_name = p.crop_manageinfo.breeds.breed_name,
  seed_date = p.seed_date.ToShortDateString(),
  pumo_type = p.pumo_type,
  guangai_type = p.guangai_type
  });
  DataTable table = DataSetLinqOperators.CopyToDataTable(result);
  return table;
  }


我用linq+ gridview显示数据,但是没能将数据库中的数据显示出来。数据库连接等应该都是没有问题的,因为我用SQL测试,可以将数据正确地显示出来。

求解啊。谢谢。



------解决方案--------------------
return table;

加个断点
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: