Thanks in advance.
Can anyone please help me get this button working so I can display a row from the Northwind database 'only' when the button is clicked.
I have been doing webgrid tutorials; however, in each tutorial the grid/ webgrid is always showing before it is searched.
It would be great if I could learn how to use a button to show data from a row in the Northwind database in a list/label/table or grid 'only' when a form is submitted.
Keeping it simple, I have this:
@{
Layout = "~/_Layout.cshtml";
Page.Title = "Compare";
var db = Database.Open("Northwind");
var selectedData = db.Query("SELECT * FROM Products");
<h1>Products</h1>
<form action="" method="post">
<div>
<input type="Submit" value="Get Products" /><br/> <br/>
</div>
</form>
<ol>
@foreach(var row in selectedData)
{
<li><a href="#">@row.ProductName</a></li>
}
</ol>
}
EDIT: In Mike's tutorial (at: http://www.mikesdotnetting.com/Article/211/Adding-A-Footer-To-The-Razor-WebGrid) Mike uses a webgrid in Razor to access the Northwind database and display orders.
I would like to use form data to access the database with a submit button; is this possible please? If so how? Thanks.