Some sample code is provided under Using the code heading and complete code is available in the project download.
In this article a GridView control is used. Inside the GridView control there are 3 fields. One template field and two are bound fields to display some sample data.
Inside the TemplateField a CheckBox control is placed in the HeaderTemplate (with ID cbSelectAll and Text Select All), ItemTemplate and AlternatingItemTemplate.
Using the code
Code that will be required to achieve this task.
Code required to add an attribute of cbSelectAll CheckBox is as follow:
protected void Page_Load(object sender, EventArgs e)
this.GridView1.DataSource = FillDataTable();
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Header)
((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
Before clicking the Select All CheckBox
After clicking the Select All CheckBox