java script is not working for styles in gridview RRS feed

  • Question

  • User-600437734 posted

    Hi ,

    I am using .Net 4.5 framework and using jquery-1.9.1.min.js.

    my javascript code is

    gridview[i].cells[4].style.display = "none";

    it is not working.

    how to resolve this.

    I am hiding grid columns dynamically using Java script.

    Tuesday, May 8, 2018 9:43 PM


  • User36583972 posted

    Hi Tejasvi,

    I am hiding grid columns dynamically using Java script.

    You can try the following code.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <script language="JavaScript">
            function hideColumn() {
                col_num = document.getElementById("column_numbder").value;
                rows = document.getElementById("GridView1").rows;
                for (i = 0; i < rows.length; i++) {
                    rows[i].cells[col_num].style.display = "none";
                 return false;
        <form id="form1" runat="server">
                <asp:GridView ID="GridView1" runat="server">
            <input id="column_numbder" type="text">
            <br />
            <asp:Button ID="Button1" runat="server" Text="Hide" OnClientClick="Javascript:return hideColumn();" />

    How to Hide GridView Column using Javascript on ButtonClick in asp.net

    Best Regards,

    Yong Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 9, 2018 2:13 AM