为什么js中的getElementById(“gridviewid”)获取不到gridview的值
为什么js中的getElementById(“gridviewid”)获取不到gridview的值varrowcount=document.getElementById(...
为什么js中的getElementById(“gridviewid”)获取不到gridview的值
var rowcount=document.getElementById("gvUserInfo").rows.length;
alert(rowcount);
下面是gridview的代码,嵌套在模版页理
<asp:GridView ID="gvUserInfo" runat="server" Width="100%" align="center" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" DataKeyNames="userid" OnRowDataBound="gvUserInfo_RowDataBound">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="选定(√)">
<ItemTemplate>
<input id="checkSimple" type="checkbox" runat="server" onfocus="changeColor(this)" />选择
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="userid" HeaderText="用户Id" />
<asp:BoundField DataField="username" HeaderText="用户姓名" />
<asp:BoundField DataField="password" HeaderText="密码" />
<asp:TemplateField HeaderText="角色">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Eval("userrole.rolename") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用户详情">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<a href="#" onclick="changeColor(this)" id="hhshow">查看详情</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView> 展开
var rowcount=document.getElementById("gvUserInfo").rows.length;
alert(rowcount);
下面是gridview的代码,嵌套在模版页理
<asp:GridView ID="gvUserInfo" runat="server" Width="100%" align="center" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" DataKeyNames="userid" OnRowDataBound="gvUserInfo_RowDataBound">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="选定(√)">
<ItemTemplate>
<input id="checkSimple" type="checkbox" runat="server" onfocus="changeColor(this)" />选择
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="userid" HeaderText="用户Id" />
<asp:BoundField DataField="username" HeaderText="用户姓名" />
<asp:BoundField DataField="password" HeaderText="密码" />
<asp:TemplateField HeaderText="角色">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Eval("userrole.rolename") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用户详情">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<a href="#" onclick="changeColor(this)" id="hhshow">查看详情</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询