Customer.aspx Code

Code:

        <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Customer.aspx.vb" Inherits="Customer" %>
        
        <!DOCTYPE html>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title>Customer Overview</title>
            <style>
                body {
                    font-family: Arial, sans-serif;
                    background-color: #ffffff;
                    color: #000000;
                    margin: 0;
                    padding: 0;
                }

                header {
                    background-color: #333;
                    color: #fff;
                    padding: 20px;
                    text-align: center;
                    font-size: 24px;
                }

                .main-container {
                    padding: 20px;
                    max-width: 1000px;
                    margin: 0 auto;
                }

                h2 {
                    font-size: 20px;
                    margin-bottom: 20px;
                    text-align: center;
                    border-bottom: 2px solid #999;
                    padding-bottom: 10px;
                }

                .gridview {
                    width: 100%;
                    border-collapse: collapse;
                }

                .gridview th {
                    background-color: #ddd;
                    color: #000;
                    padding: 12px;
                    border: 1px solid #999;
                    text-align: left;
                }

                .gridview td {
                    padding: 12px;
                    border: 1px solid #999;
                }

                .gridview tr:nth-child(even) td {
                    background-color: #f5f5f5;
                }

                .gridview tr:hover td {
                    background-color: #e0e0e0;
                }

                footer {
                    background-color: #333;
                    color: #fff;
                    text-align: center;
                    padding: 10px;
                    font-size: 14px;
                    position: relative;
                    bottom: 0;
                    width: 100%;
                    margin-top: 40px;
                }
            </style>
        </head>
        <body>
            <form id="form1" runat="server">
                <header>Customer Overview</header>
                <div class="main-container">
                    <h2>Latest 5 Registered Customers</h2>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" CssClass="gridview" />
                </div>
                <footer>© 2025 Food Reservation System</footer>
            </form>
        </body>
        </html>
    

Customer.aspx.vb Code

Code:

        Imports System.Data
        Imports System.Data.SqlClient

        Partial Class Customer
            Inherits System.Web.UI.Page

            Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
                If Not IsPostBack Then
                    DisplayCustomerRecords()
                End If
            End Sub

            Private Sub DisplayCustomerRecords()
                Dim connectionString As String = "workstation id=HussainDatabse.mssql.somee.com;packet size=4096;user id=hussain123_SQLLogin_1;pwd=ss7xmwadf2;data source=HussainDatabse.mssql.somee.com;persist security info=False;initial catalog=HussainDatabse;TrustServerCertificate=True"
                Dim query As String = "SELECT TOP 5 * FROM Customer"

                Using connection As New SqlConnection(connectionString),
                      adapter As New SqlDataAdapter(query, connection)

                    Dim customerTable As New DataTable()
                    adapter.Fill(customerTable)

                    GridView1.DataSource = customerTable
                    GridView1.DataBind()
                End Using
            End Sub
        End Class