Как получить идентификатор элементов управления в childGridview внутри родительского gridview в функции javascript (ID ="ui_access" )
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 %>"); } } }
<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>
Когда я пишу gvParentGrid.gvChildGrid.ClientID таким образом, это дает gvChildGrid ошибки не существует.