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

请问一个asp页面的datagrid里面的有部分行的控件取不到值,如果去掉一部分行则可以全部控件都取得到值(ps:去掉的那一部分行不是之前取不到控件值的行)!
请问一个asp页面的datagrid里面的有部分行的控件取不到值,如果去掉一部分行则可以全部控件都取得到值(ps:去掉的那一部分行不是之前取不到控件值的行)! 这个问题是什么原因?
 foreach (DataGridItem scoreGridItem in dgPM_OrgObjectiveRecord.Items)
  {
  int itemId = SafeConvert.ToInt32(dgPM_OrgObjectiveRecord.DataKeys[scoreGridItem.ItemIndex].ToString());
  DataRow[] drs = dt.Select(string.Concat("Id=", itemId));
  DataRow drv = drs[0];
  double rowScore = 0;
  if (itemId != PM_OrgObjectiveRecordService.TOTAL_ROW_ID)
  {

  if (drs.Length > 0)
  {
   
  for (int i = colCount - dgScoreEndIndex; i < colCount; i++)
  {  
  string id = dgPM_OrgObjectiveRecord.Columns[i].SortExpression;
  if (i < colCount - 1)
  {
  string[] cod = id.Split('_');
  WFMGM_DefActBaseInfo wf = scorer.Where(o => o.RuntimeParticipantCode.IndexOf(cod[1]) != -1).FirstOrDefault();
  if (!string.IsNullOrEmpty(id))
  {
  HtmlInputHidden htmlScore = scoreGridItem.FindControl(string.Concat("htmlScore_", id)) as HtmlInputHidden;
  }
  }
  }
  }
  }
  }

其中就是 htmlScore 取不到控件的值(控件的值在后台已经赋值了),控件本身是可以取到的!
注意的是:
  我所有的DataBind()都放在
  if (!Page.IsPostBack) 
  {
  OrgObjectiveRecord.DataBind();
  }
本人现在怀疑是viewstate过大导致asp页面数据post问题,请各位大神帮帮忙解决一下!

------解决方案--------------------
htmlScore 控件是服务器端控件吗,建议换成普通的textbox