protected void Page_Load(object sender, EventArgs e) { try { BookBL bookBL = new BookBL(); string search_Str = Request.QueryString["search"].ToString();//查詢字串 Label5.Text = search_Str; Label3.Text = "0"; string activePage = Request.QueryString["page"] == null ? "1" : Request.QueryString["page"]; string type = Request.QueryString["type"].ToString(); switch (Request.QueryString["type"]) { //書籍名稱查詢 case "1": Label3.Text = bookBL.BookNameSearchCount(search_Str); bookBL.Pages(Panel1, activePage, Convert.ToInt32(Label3.Text), type, search_Str); DataList1.DataSource = bookBL.BookNameSearch(search_Str, Convert.ToInt32(activePage)); DataList1.DataBind(); break; //作者書籍查詢 case "2": Label3.Text = bookBL.BookAuthorSearchCount(search_Str); bookBL.Pages(Panel1, activePage, Convert.ToInt32(Label3.Text), type, search_Str); DataList1.DataSource = bookBL.BookAuthorSearch(search_Str, Convert.ToInt32(activePage)); DataList1.DataBind(); break; //出版社書籍查詢 case "3": Label3.Text = bookBL.BookPublisherSearchCount(search_Str); bookBL.Pages(Panel1, activePage, Convert.ToInt32(Label3.Text), type, search_Str); DataList1.DataSource = bookBL.BookPublisherSearch(search_Str, Convert.ToInt32(activePage)); bookBL.BookPublisherSearch(search_Str, Convert.ToInt32(activePage)); DataList1.DataBind(); break; //書籍ISBN查詢 case "4": Label3.Text = bookBL.BookISBNSearchCount(search_Str); bookBL.Pages(Panel1, activePage, Convert.ToInt32(Label3.Text), type, search_Str); DataList1.DataSource = bookBL.BookISBNSearch(search_Str, Convert.ToInt32(activePage)); DataList1.DataBind(); break; } if (Label3.Text == "0") { Label4.Text = "查詢不到您的資料!"; } else { Label4.Visible = false; } } catch (Exception ex) { ex.ToString(); } }