nord vpnnord vpn
Ad

Untitled

mail@pastecode.io avatar
unknown
html
a month ago
1.6 kB
4
Indexable
Never
@using WebMatrix.Data;

@{
    var db = Database.Open("AmazonOrders");

    var sql = "SELECT * FROM Items WHERE itemName LIKE CONCAT(@0, '%') ORDER BY itemName ASC";

    var data = db.Query(sql, Request.Form["SearchText"]);

}

<h2 class="text-center">Home</h2>

<form method="post" action="/Home/Index" class="row">
    <div class="col-3"><input type="text" name="searchText" class="form-control" placeholder="Search Products" /></div>
    <div class="col-2"><button type="submit" class="btn btn-primary">Search</button></div>
</form>
<hr />


@foreach (var row in data)
{
    @row.itemName
}

@for (var i = 0; i < data.Count(); i++)
{
    @data.ElementAt(i).itemName;
}


@if (data.Count() > 0)
{
    <div class="row justify-content-center">
        @{
            foreach (var row in data)
            {
                <div class="card col-3 m-1">
                    <img src="@row.itemImage" class="card-img-top" alt="@row.itemName image" />
                    <div class="card-body">
                        <h5 class="card-title">@row.itemName</h5>
                        <p class="card-text">@row.itemDescription</p>
                        <p class="font-italic">@row.itemCost.ToString("C")</p>
                        <a href="/Home/Details?id=@row.itemID" class="btn btn-secondary" target="_blank">View Detail</a>
                    </div>
                </div>
            }
        }
    </div>
}
else
{
    <h2 class="text-danger text-center">Ooops ! No matching products returned...</h2>
}

nord vpnnord vpn
Ad