日期:2014-05-16  浏览次数:20320 次

javascript获取gridview值失败!
我要用javascript获取girdview内的值,报错:0x800a138f - JavaScript 运行时错误: 无法获取未定义或 null 引用的属性“rows”
代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChooseCustomerPage.aspx.cs" Inherits="ChooseCustomerPage" %>
<%@ Register Assembly="MyControls" Namespace="MyControls" TagPrefix="cc1" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript">
        function save() {
            var table = document.getElementById(<%=GridView1.ClientID %>);
            var rowindex = 0;
            for(var i=1;i<table.rows.length;i++) 
            { 
                var input = table.rows[i].cells[0].getElementsByTagName("input")[0].checked; 
                if (input == true) 
                { 
                    rowIndex = i; 
                    return rowindex;
                } 
            }             
        }
        function closeShow() {
            window.close();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="选择客户:"></asp:Label>
        <cc1:MyGridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" CellPadding="4" 
            ForeColor="#333333" 
            OnPageIndexChanging="GridView1_PageIndexChanging" 
            PageSize="8" 
            hoverBackColor=""
            hoverTextColor="">
            <AlternatingRowStyle BackColor="White" />
    &nb