function for select/unselect all checkboxs by clicking on one chechbox?

Discussion in 'JavaScript' started by raspms, Mar 22, 2012.

  1. #1
    hello,
    i have one gridview on that i take one checkbox named as select all when i clicked on that all checkboxes should be checked but when i deselected the select all checkbox then their should be unselected chechbox with others.
    can anybody tell me in javascript function how can i do it?
    give me code please...
     
    raspms, Mar 22, 2012 IP
  2. phapit

    phapit Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you post the html? That is actually fairly easy.
     
    phapit, Mar 24, 2012 IP
  3. raspms

    raspms Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this is the checkbox on the gridview as per your suggestion:
    <asp:TemplateField HeaderText="Select all">
    <ItemTemplate>
    <asp:CheckBox ID="chkselectchild" runat="server" />
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
    <HeaderTemplate>
    <asp:CheckBox ID="chkselectall" runat="server"
    Text="Select All" />
    </HeaderTemplate>
    </asp:TemplateField>
     
    raspms, Mar 28, 2012 IP