Error in getting row count using javascript
<p>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</p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;
function CheckSites() {

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

<p>This is how I am calling that function...</p>

<pre><code>&lt;asp:Button ID="btnAdd" runat="server" Text="Save" OnClick="btnAdd_Click" OnClientClick="CheckSites()"/&gt;
</code></pre>

<p>This is the definition of my gridview</p>

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

<p>Please guide me where/what I am making mistake mistake...</p>

<p>Thanks</p>
