ASP.NET Web Pages - WebGrid အုံးပုံ

WebGrid - အသုံးပြုရန် အရေးပါသော အီလက်ထရောနစ် ဝန်ဆောင်မှု တစ်ခု

လုပ်ဆောင်ခြင်း

အရင်လေ့လာမှုများတွင် ကျွန်ုပ်တို့သည် အခြေခံ ရှိသော ရှင်းလင်းချက် အား အသုံးပြု၍ ဖော်ပြခြင်း နှင့် အတိုက်အခံ အီလက်ထရောနစ် လက္ခဏာ အား လုပ်ဆောင်ခဲ့သည်။

Database အမှုံအရေး

@{
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>

အမှုလုပ် အပြောင်း

Using WebGrid Helper

Using WebGrid Helper is a simpler way to display data.

WebGrid Helper:

  • Automatically create HTML table to display data
  • Support different formatting options
  • Support data pagination
  • Support click column title for sorting

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>

အမှုလုပ် အပြောင်း