Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
function SelectAll(CheckBox) {

        var chkAc1 = document.getElementById('ctl00_MainContent_CheckBoxAccess').checked;
            if (document.getElementById('ctl00_MainContent_CheckBoxAccess').checked) {
                var ParentGrid = document.getElementById("<%= gvParentGrid.ClientID %>");
                if (ParentGrid.rows.length > 0) {
                   var chidgrid = document.getElementById("<%= gvParentGrid.gvChildGrid.ClientID %>");
            }
}
}


XML
<asp:GridView ID="gvParentGrid" ShowHeaderWhenEmpty="true" runat="server" DataKeyNames="ui_name" Width="100%"
                   AutoGenerateColumns="false" OnRowDataBound="gvParent_RowDataBound" GridLines="none" ShowHeader="false" >
                   <HeaderStyle Height="0px" HorizontalAlign="Center" Font-Size="5px" VerticalAlign="Middle"></HeaderStyle>
                   <RowStyle CssClass="DG_ItemStyle" HorizontalAlign="left"  VerticalAlign="Middle"/>
                   <AlternatingRowStyle CssClass="DG_ItemStyle" HorizontalAlign="left" VerticalAlign="Middle"/>
                   <Columns>
                      <asp:TemplateField>
                           <ItemTemplate>
                           <tr>
                           <td colspan="100%">
                           <div id="div<%# Eval("ID") %>" style="display: BLOCK; position: relative; left: 15px; overflow: auto;">
                                <asp:GridView ID="gvChildGrid" runat="server" OnRowDataBound="gvChild_RowDataBound" AutoGenerateColumns="false" GridLines="none"  Width="650px" >
                               <HeaderStyle Height="32px" CssClass="DG_ChildHeaderStyle" Font-Bold="true" HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                               <RowStyle CssClass="DG_ItemStyle" HorizontalAlign="left"  VerticalAlign="Middle"/>
                               <AlternatingRowStyle CssClass="DG_AlternateItemStyle" HorizontalAlign="left" VerticalAlign="Middle"/>
                               <Columns>
                                   <asp:BoundField DataField="UI_NAME" HeaderText="" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="20%" />
                                    <asp:TemplateField HeaderText="Access" HeaderStyle-HorizontalAlign="Left" >
                                       <ItemTemplate>
                                           <asp:CheckBox runat="server" ID="ui_access" />
                                       </ItemTemplate>
                                   </asp:TemplateField>


When i write gvParentGrid.gvChildGrid.ClientID it gives error gvChildGrid does not exists.
Posted
Updated 22-Jan-20 19:12pm
v7

1 solution

Hi,

You can do it with jquery.Check following script,

JavaScript
var chidgrid = $('#<%= gvParentGrid.ClientID %> table');


variable chidgrid have all childgrid elements of gvParentGrid.

Hope it helps you.
 
Share this answer
 
v2
Comments
Member 9410081 5-Aug-13 5:39am    
Thanks i will check out
Member 9410081 5-Aug-13 5:58am    
Thanks it is working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900