动态生成checkbox,怎么判断是否选中 急急急急急
/// <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>();