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()">
<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.
<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()">
<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.
Comment