我正在使用 linq 连接到数据库,这是我第一次显示来自数据库的大量数据,所以我不知道如何处理它..你能给我提示吗?谢谢!
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
rebind();
}
private void rebind()
{
using ( var db = new linqDataContext())
{
GridView1.DataSource = db.Orders.Select(p => new { p.OrderID, p.CustomerID, p.ShipName, p.ShipCity }).ToList();
GridView1.DataBind();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
rebind();
}
}