How to hide gridview on open

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rick Beach
    New Member
    • Jan 2011
    • 25

    How to hide gridview on open

    The below programming works properly to show and hide gridviews:

    <script type="text/javascript">
    function hideGrid()
    {document.getEl ementById("Grid view3").style.d ispla y = "none";}

    function showGrid()
    {document.getEl ementById("Grid view3").style.d ispla y = "block";}
    </script>

    <INPUT Type="button" Value="Show Material List" OnClick="showGr id()">
    &nbsp;&nbsp;
    <INPUT Type="button" Value="Hide Material List" OnClick="hideGr id()">

    <div id="Gridview3" >
    <asp:GridView ID="GridView3" runat="server" AutoGenerateCol umns="False"
    DataSourceID="S qlDataSource2"
    style="text-align: center; margin-left: 370px;">
    <Columns>
    <asp:BoundFie ld DataField="Item ID" HeaderText="Ite mID" SortExpression= "ItemID">
    <HeaderStyle Width="50px"></HeaderStyle>
    </asp:BoundField>
    <asp:BoundFie ld DataField="Item Desc" HeaderText="Ite mDesc" SortExpression= "ItemDesc">
    <HeaderStyle Width="400px"></HeaderStyle>
    </asp:BoundField>
    </Columns>
    </asp:GridView>
    </div>

    What I need is to have the gridview hidden when the page opens. If I set the visible property of the gridview to false, I cannot view the page even with the "Show Material List" button created above.
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Using javascript onload event set the gridview to be hidden.

    Happy programming,
    CroCrew~

    Comment

    • Rick Beach
      New Member
      • Jan 2011
      • 25

      #3
      I had attempted this but was not placing this in the right location. This needed to be in the HEAD section and used the BODY ONLOAD event to run the script. This works properly. I appreciate your assistance.

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        Anytime. Have fun~

        Comment

        • aspdotnetuser
          New Member
          • Nov 2010
          • 22

          #5
          enclose the gridview inside a asp:Panel.Perfo rm show/hide of the panel rather the gridview..Hope this works..

          Comment

          Working...