I want to search Record id form asp.net Gridview, I have used a textbox and create a function in javascript and then search value from the client side. I am facing this problem I have shared error and code.
ERROR
APIData:119 Uncaught TypeError: Cannot read property 'rows' of null
at Search_Gridview (APIData:119)
at HTMLInputElement.onkeyup (APIData:229)
<asp:TextBox ID="txtSearchBox" runat="server" Font-Size="20px" onkeyup="Search_Gridview(this,'GridView1')"></asp:TextBox>
<asp:GridView ID="GridView1" runat="server" CellPadding="10" Width="500px">
</asp:GridView>
function Search_Gridview(strKey, gvdata) {
var strData = strKey.value.toLowerCase().split(" ");
var tblData = document.getElementById("gvdata");
var rowData;
for (var i = 1; i < tblData.rows.length; i++) {
rowData = tblData.rows[i].innerHTML;
var styleDisplay = 'none';
for (var j = 0; j < strData.length; j++) {
if (rowData.toLowerCase().indexOf(strData[j]) >= 0)
styleDisplay = '';
else {
styleDisplay = 'none';
break;
}
}
tblData.rows[i].style.display = styleDisplay;
}
}
Comments
Post a Comment