How to Select all checkbox in griedview in
//First step:Take a grid view and checkbox
           <asp:GridView ID="GridView1" runat="server" Height="131px" Width="500px" DataKeyNames="Id"
            AutoGenerateColumns="False" Style="margin-top: 2px; margin-left: 0px; margin-bottom: 1px;">
                <asp:TemplateField HeaderText="Action">
                        <asp:CheckBox ID="chkRow" runat="server" />

//second step:take a button for select all checkbox
             //double click on button and write code
protected void Button2_Click(object sender, EventArgs e)
        CheckState(b);//this is function 
//make global variable
  bool b=true;
//make a function
 private void CheckState(bool p)
        foreach (GridViewRow row in GridView1.Rows)
            CheckBox chkcheck = (CheckBox)row.FindControl("chkRow");
            chkcheck.Checked = p;
  Modified On Sep-18-2014 01:24:23 PM

Leave Comment