title: Retain Visible Attribute for GridView After Page Refresh (ASP.NET, C#)
body: <ul>
  <li>OK so I assume I need to use SessionData but I can't seem to figure it out.</li>
  <li>What I have is a GridView with a button that toggles its visibility</li>
  <li>Another button that adds data the GridView and refreshes the page to view it immediately.</li>
  <li>My problem is when the page refreshes, the GridView becomes invisible again until I click the button, how can I keep it how it was prior to refreshing.</li>
  </ul>
  
  <p>GridView</p>
  
  <pre><code>    &lt;asp:GridView ID="GridViewPrograms" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource" CssClass="Grid"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="Firstname" HeaderText="Firstname" SortExpression="Firstname" ReadOnly="True" /&gt;
          &lt;asp:BoundField DataField="MiddleName" HeaderText="MiddleName" SortExpression="MiddleName" ReadOnly="True" /&gt;
          &lt;asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" ReadOnly="True" /&gt;
          &lt;asp:BoundField DataField="ProgramID" HeaderText="ProgramID" InsertVisible="False" ReadOnly="True" SortExpression="ProgramID" /&gt;
          &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" ReadOnly="True" /&gt;
          &lt;asp:BoundField DataField="ProgramDate" HeaderText="ProgramDate" SortExpression="ProgramDate" ReadOnly="True" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;&lt;br /&gt;
  </code></pre>
  
  <p>Button I have to toggle visibility of GridView</p>
  
  <pre><code>protected void ButtonPrograms_Click(object sender, EventArgs e) {
      //Change Text Based on Button State
      if (ButtonPrograms.Text == "Programs") {
          ButtonPrograms.Text = "Hide";
      }
      else if (ButtonPrograms.Text == "Hide") {
          ButtonPrograms.Text = "Programs";
      }
  
      if (GridViewPrograms.Visible == true) {
          GridViewPrograms.Visible = false;
      }
      else if (GridViewPrograms.Visible == false) {
          GridViewPrograms.Visible = true;
      }
  }
  </code></pre>