Latest web development tutorials

Páginas Web ASP.NET WebGrid

WebGrid - uno de los muchos útiles Web ASP.NET ayudante.


Escribir su propio código HTML

En la sección anterior, que utilizó código de la maquinilla de afeitar muestra los datos de bases de datos, todas las etiquetas HTML son manuscrita:

Instancia de base de datos

@{
var db = Database.Open("SmallBakery");
var selectQueryString = "SELECT * FROM Product ORDER BY Name";
}

<html>
<body>
<h1>Small Bakery Products</h1>
<table>
<tr>
<th>Id</th>
<th>Product</th>
<th>Description</th>
<th>Price</th>
</tr>
@foreach(var row in db.Query(selectQueryString))
{

<tr>
<td> @row.Id </td>
<td> @row.Name </td>
<td> @row.Description </td>
<td align="right"> @row.Price </td>
</tr>
}
</table>
</body>
</html>

Instancia en ejecución »


Uso WebGrid ayudante

WebGrid ayudante proporciona una visualización sencilla de más datos.

WebGrid ayudante:

  • Crea automáticamente una tabla HTML para mostrar los datos
  • Es compatible con diferentes opciones de formato
  • datos de soporte de paginación
  • Apoyo a ordenar la lista haciendo clic en el título

instancia WebGrid

@{
var db = Database.Open("SmallBakery") ;
var selectQueryString = "SELECT * FROM Product ORDER BY Id";
var data = db.Query(selectQueryString);
var grid = new WebGrid(data);
}

<html>
<head>
<title>Displaying Data Using the WebGrid Helper</title>
</head>
<body>
<h1>Small Bakery Products</h1>
<div id="grid">
@grid.GetHtml()
</div>
</body>
</html>

Instancia en ejecución »