Mistake in you code(wrong control name in js code)
This line
var gridview1 = document.getElementById('<%=grdview1.ClientID %>');
should be
var gridview1 = document.getElementById('<%=Gridview1.ClientID %>');
Gridview1
is the ID of the GridView control