1、工程和項目結構

在DAL層,我們主要是通過IBatisNet進行數據訪問的控制和實現。如果你不清楚IBatisNet也沒有關系,你就設想IBatisNet在這裡的作用就是,按照查詢條件,返回一個泛型數據列表集合,這樣理解就可以了。
在本文的示例代碼中,通過輸入FirstName和(或)LastName模糊匹配查詢某些人,並通過一個GridView分頁顯示出來。傳參的過程很重要,在兩個TextBox中輸入後,在程序中我們要分析具體是點擊按鈕還是直接點擊數字進行分頁查詢,所以下面的Page Load的數據初始化過程是很重要的:
01
protected int currentPg = 1;
02
protected int totalCount = 0;
03
protected int recordsPerPg = 10;
04
private int leftSize = 3;
05
private IList<Person> listPerson = null;
06
protected void Page_Load(object sender, EventArgs e)
07
{
08
if (IsPostBack == false && string.Compare(Request.RequestType.ToLower(), "get") == 0)
09
{
10
if (string.IsNullOrEmpty(Request["pageIndex"]) == false && RegUtil.IsPositiveNumber(Request["pageIndex"]))
11
{
12
currentPg = int.Parse(Request["pageIndex"]);
13
}
14
if (string.IsNullOrEmpty(Request["firstname"]) == false)
15
{
16
this.txtFirstName.Text = Request[<