var grid=(document.getElementById("<%=gvAssignedTickets.ClientID%>"))?document.getElementById("<%=gvAssignedTickets.ClientID%>"):null; if (grid) { if (grid.rows.length>0) { ... } }