本文介绍了如何在javascript函数中的父网格视图中获取childGridview中的控件的ID(ID为=" ui_access")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!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不存在。When i write gvParentGrid.gvChildGrid.ClientID it gives error gvChildGrid does not exists.推荐答案var chidgrid = 变量chidgrid拥有gvParentGrid的所有childgrid元素。 希望它可以帮到你。 variable chidgrid have all childgrid elements of gvParentGrid.Hope it helps you. 这篇关于如何在javascript函数中的父网格视图中获取childGridview中的控件的ID(ID为=" ui_access")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-18 21:38