+ -
当前位置:首页 → 问答吧 → 动态生成checkbox,怎么判断是否选中 急急急急急

动态生成checkbox,怎么判断是否选中 急急急急急

时间:2011-07-13

来源:互联网

/// <summary>
  /// 自动生成复选按钮
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  protected void gridTb_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  if (e.Row.RowType != DataControlRowType.DataRow)
  {
  return;
  }
  else 
  {  
  bool cellChecked = true; //默认全选状态
  string key = gridTb.PageIndex + "_" + e.Row.RowIndex;
  if (checkList.ContainsKey(key))
  {
  cellChecked = checkList[key];
  }
  checkList.Add(key, cellChecked);
  Label l = new Label();
  l.Text = e.Row.Cells[0].Text;
  CheckBox c = new CheckBox();
  c.Checked = cellChecked;
  e.Row.Cells[0].Controls.Add(c);
  //e.Row.Cells[0].Controls.Add(l);
  }
  }
  private Dictionary<string, bool> checkList = new Dictionary<string, bool>();

作者: cuiguangh   发布时间: 2011-07-13

在服务器端还是在浏览器?

作者: aspwebchh   发布时间: 2011-07-13