Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select all checkbox inside a gridview?
    primarykey
    data
    text
    <p>I want to Check the checkboxes inside a ListView which is Placed inside a Gridview. The Gridview is having many rows and Each row is having a List view with associated recrods. Each row contains a CheckBox called select all. I want to check the checkboxes of the child ListView control which accompanies that particular Row. </p> <p>I have a Server side code from which Im able to do this. but its taking too much time.. ie almost around 1-2 mins to select records if there are more than 1000 records. I want this to be done using a Javascript. how can i achieve this.</p> <p><img src="https://i.stack.imgur.com/eepNb.png" alt="Image"></p> <p>This is the image representing the GridView and ListView. GridView is Groups and Contacts is the ListView When i select the "SelectAll" button in the GridView the Appropriate contacts should be selected.</p> <p>How can I achieve this using Javascript.</p> <p>This is the code of the grid view</p> <pre><code> &lt;asp:GridView ID="GridViewGroups" runat="server" AutoGenerateColumns="False" onrowdatabound="GridViewGroups_RowDataBound" Width="100%" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" onselectedindexchanged="GridViewGroups_SelectedIndexChanged" meta:resourcekey="GridViewGroupsResource1" &gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Groups" meta:resourcekey="TemplateFieldResource1" HeaderStyle-CssClass="tSubHead"&gt; &lt;ItemTemplate&gt; &lt;div align="left" &gt; &lt;asp:Panel ID="PanelContainer" runat="server" Width="100%" meta:resourcekey="PanelContainerResource1" &gt; &lt;asp:Panel ID="PanelHeaderList" runat="server" meta:resourcekey="PanelHeaderListResource1" CssClass="tSubHead2" style="cursor:pointer;"&gt; &lt;asp:ImageButton ID="Image1" runat="server" ImageUrl="../micons/IC_Plus.png" CssClass="tImage" AlternateText="Expand or Collapse" meta:resourcekey="Image1Resource1"/&gt; &lt;asp:Label ID="LabelGrpName_sm" runat="server" Text='&lt;%# string.Format("{0} ({1})", Eval("Grp_Name"),Eval("CountNo")) %&gt;' meta:resourcekey="LabelGrpName_smResource1" /&gt; &lt;/asp:Panel&gt; &lt;div style="float:left;width:200px;" &gt; &lt;asp:HiddenField ID="hfGrpID" runat="server" Value='&lt;%# Eval("Grp_ID") %&gt;' /&gt; &lt;asp:CheckBox ID="CheckBoxSelect" runat="server" AutoPostBack="True" class='&lt;%#Eval("Grp_ID") %&gt;' OnCheckedChanged="GroupCheckChanged" meta:resourcekey="CheckBoxSelectResource1" /&gt; &lt;b&gt; &lt;asp:Label ID="Grp_NameLabel" runat="server" Text="Select All" meta:resourcekey="Grp_NameLabelResource1" /&gt; &lt;/b&gt; &lt;/div&gt; &lt;br /&gt; &lt;p&gt; &lt;asp:Panel ID="PanelGroupsItem" runat="server" Width="100%" meta:resourcekey="PanelGroupsItemResource1" &gt; &lt;asp:Panel ID="MyGroups" runat="server" ScrollBars="Vertical" Height="300px" Width="100%" Visible='&lt;%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %&gt;' meta:resourcekey="MyGroupsResource1"&gt; &lt;asp:ListView ID="ListViewContactsInGrp" runat="server" onitemdatabound="ListView1_ItemDataBound" &gt; &lt;LayoutTemplate&gt; &lt;table id="Table1" runat="server" style="width:100%;"&gt; &lt;tr id="Tr1" runat="server"&gt; &lt;td id="Td1" runat="server"&gt; &lt;table ID="itemPlaceholderContainer" runat="server" border="0" style="width:100%;"&gt; &lt;tr id="Tr2" runat="server" style=""&gt; &lt;th id="Th1" runat="server" colspan="2" class="tSubHead2"&gt; Contacts&lt;/th&gt; &lt;/tr&gt; &lt;tr ID="itemPlaceholder" runat="server"&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="Tr3" runat="server"&gt; &lt;td id="Td2" runat="server" style=""&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;tr style=""&gt; &lt;td class="tListViewAlignment" style="width:10px"&gt; &lt;asp:CheckBox ID="chkFlag" runat="server" meta:resourcekey="chkFlagResource1" class='&lt;%#Eval("grp_id") %&gt;' /&gt; &lt;/td&gt; &lt;td class="tListViewAlignment"&gt;&lt;asp:Label ID="LabelContacts" runat="server" Text='&lt;%# Eval("cont_name") %&gt;' meta:resourcekey="LabelContactsResource1"&gt;&lt;/asp:Label&gt; &lt;asp:HiddenField ID="hfGSM" runat="server" Value='&lt;%# Eval("cont_gsm") %&gt;' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; &lt;/asp:Panel&gt; &lt;/asp:Panel&gt; &lt;/p&gt; &lt;asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" Collapsed="True" TargetControlID="PanelGroupsItem" CollapseControlID="PanelHeaderList" ExpandControlID="PanelHeaderList" ImageControlID="Image1" ExpandedImage="~/micons/IC_minus.png" CollapsedImage="~/micons/IC_Plus.png" SuppressPostBack="True" Enabled="True"&gt; &lt;/asp:CollapsiblePanelExtender&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle BorderColor="Silver" /&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;HeaderStyle BorderColor="Silver" /&gt; &lt;RowStyle BorderColor="Silver" /&gt; &lt;/asp:GridView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload