title: How to display data in custom table using asp.net?
body: <p>I  want to display data from my SQL database in a custom table format.  So basically this is what I would like to achieve:</p>
  
  <p>A. To display all entries in SQL table in a gridview with a <code>view</code> button next to each row</p>
  
  <p>B. Click on the <code>view</code> button to display the below in a new web page</p>
  
  <pre><code> ______________________________________
  |           Customer Info              |
  ----------------------------------------
  |Customer Name:   "From DB Table"      |
  |Address:         "From DB Table"      |
  ----------------------------------------
  </code></pre>
  
  <p>Then the next <code>table</code> below the one above</p>
  
  <pre><code> ______________________________________
  |           Customer Network           |
  ----------------------------------------
  |Network Location:   "From DB Table"   |
  |APs:                "From DB Table"   |
  ----------------------------------------
  </code></pre>
  
  <p>All of the above is from one <code>ID</code> in my SQL DB table.  So I want to break it up into sections to display all the data in the SQL Table</p>
  
  <p>I don't have any code yet as I am not sure on how to do this.</p>
  
  <p>To sum up: 
  When the page loads it the shows all the entries in the database in a <code>gridview</code> with a view button next to each row</p>
  
  <p>Then when the user clicks on the <code>view</code> button it opens a new page with the above table.</p>
  
  <p>Thanks</p>
  
  <p><strong>CODE</strong></p>
  
  <p>GridView</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"&gt;
      &lt;FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /&gt;
      &lt;HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
      &lt;RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /&gt;
      &lt;SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /&gt;
      &lt;SortedAscendingCellStyle BackColor="#FFF1D4" /&gt;
      &lt;SortedAscendingHeaderStyle BackColor="#B95C30" /&gt;
      &lt;SortedDescendingCellStyle BackColor="#F1E5CE" /&gt;
      &lt;SortedDescendingHeaderStyle BackColor="#93451F" /&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Then Code Behind</p>
  
  <pre><code>                GridView1.DataSource = GetData();
                  GridView1.DataBind();
              }
          }
      }
  
      DataTable GetData()
      {
          DataTable dt = new DataTable();
          using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["OfficeConnection"].ConnectionString))
          {
              con.Open();
              using (SqlCommand cmd = new SqlCommand("SELECT DisplayName 'Display Name', Replace(PrimaryEmailAddress,'SMTP:', ' ') 'Email Address', Replace(Licenses,'reseller-account:', ' ') 'License Type', LastPasswordChangeTimestamp 'Last Password Reset' FROM Consulting ", con))
              {
                  for (int i = dt.Rows.Count - 1; i &gt;= 0; i--)
                  {
                      if (dt.Rows[i][1] == DBNull.Value)
                          dt.Rows[i].Delete();
                  }
                  dt.AcceptChanges();
                  SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                  adpt.Fill(dt);
              }
  
          }
          return dt;
      }
  }
  }
  </code></pre>
  
  <p>This is some code from a different section in my web app.  I can use the same code with a few changes, but how do I add the View button and to achieve the above question?</p>