Greetings! New here, first post, looking for some help

  <script type="text/javascript">
            function Search_Gridview(strKey, strGV) {
               // debugger;
            var strData = strKey.value.toLowerCase().split(" ");
            var tblData = document.getElementById("strGV");
            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;
            }
        }    
    </script>

<div style="border: 1px solid Black; width: 800px; padding: 20px; height: 350px;
            font-size: 20px;">
            Search :
            <asp:TextBox ID="txtSearch" runat="server" Font-Size="20px" onkeyup="Search_Gridview(this, 'gvTest')"></asp:TextBox><br />
            <br />
            <asp:GridView ID="gvTest" runat="server" OnPageIndexChanging="GrdRole_PageIndexChanging" PageSize="10000" AllowPaging="true" CellPadding="10" Width="500px">
                <columns>
               <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="chkSelect" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            </columns>
            </asp:GridView>
        </div>

i am getting error in -
var tblData = document.getElementById(“strGV”); (Uncaught TypeError: Cannot read property ‘rows’ of null)
this javascript is for live search gridview.

Maybe it’s a bit early in the day for me, but I can’t see an ID of “strGV” in your HTML. The only ID’s I see are “gvTest”, “txtSearch” and “chkSelect”.

It’s being passed to the function as an argument.

can you tell me which line i did wrong?

I don’t know if it is necessarily the only problem. but if you look at the two arguments the function is using, can you spot the difference in the syntax?

function Search_Gridview(strKey, strGV) {
// debugger;
  var strData = strKey.value.toLowerCase().split(" ");
  var tblData = document.getElementById("strGV");

Thanks. That wasn’t what I was looking for.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.