当我点击标题中的复选框时,它应该选择中的所有复选框 那一栏。我没有使用项目模板和标题模板 复选框。
protected void gv_ProjectResourceDatasetAccess_RowDataBound(object
sender, GridViewRowEventArgs e)
{
//DataRowView drview = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
CheckBox chk = new CheckBox();
chk.Text = e.Row.Cells[i].Text;
e.Row.Cells[i].Controls.Add(chk);
e.Row.Cells[i].Attributes.Add("OnClick", "return
SelectAll(this)");
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
int i = 0;
foreach (DataColumn col in ds_DatasetAccess.Tables[0].Columns) {
CheckBox cb = new CheckBox();
// cb.id = ... and other control setup
// add your control here:
e.Row.Cells[i].Controls.Add(cb);
i++;
}
}
}
<asp:GridView id="gv_ProjectResourceDatasetAccess" runat="server"
OnRowDataBound="gv_ProjectResourceDatasetAccess_RowDataBound"
CssClass="table datatable-basic table-striped table-hover dataTable no-
footer"></asp:GridView>