I am trying to get the row count of grid view using javascript. Javascript is called but some how I am not getting row count. This is the code for my javascript

```
<script language="javascript" type="text/javascript">
function CheckSites() {

    var Grid = document.getElementByID(<%=grdSiteInformation.ClientID%>);
    var row = Grid.rows.length;
    alert(grid);
if(length=0)
    alert('Enter atleast one site');
    }
</script>

```

This is how I am calling that function...

```
<asp:Button ID="btnAdd" runat="server" Text="Save" OnClick="btnAdd_Click" OnClientClick="CheckSites()"/>

```

This is the definition of my gridview

```
<asp:GridView ID="grdSiteInformation" runat="server" AutoGenerateColumns="False"
                        OnRowCommand="grdSiteInformation_RowCommand">
                        <Columns>
                            <asp:BoundField DataField="TableRowIndex" HeaderText="Sr.No" />
                            <asp:BoundField DataField="SiteID" HeaderText="SiteID" />
                            <asp:BoundField DataField="POrderID" HeaderText="POrderID" />
                            <asp:BoundField DataField="SiteName" HeaderText="SiteName" />
                            <asp:BoundField DataField="Location" HeaderText="Location" />
                            <asp:BoundField DataField="SiteAddress" HeaderText="SiteAddress" />
                            <asp:BoundField DataField="Cluster" HeaderText="Cluster" />
                            <asp:BoundField DataField="SubVendorName" HeaderText="SubVendorName" />
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Button ID="btnEdit" runat="server" CommandArgument='<%# Eval("SiteID") %>' CommandName="Edt"
                                        Text="Edit" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                    Edit
                                </HeaderTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

```

Please guide me where/what I am making mistake mistake...

Thanks