protected void Page_Load(object sender, EventArgs e) { try { BookBL bookBL = new BookBL(); string activePage = Request.QueryString["page"] == null ? "1" : Request.QueryString["page"]; int dataCount = Convert.ToInt32(bookBL.bookListCount(Request.QueryString["type"], Request.QueryString["class_id"], Request.QueryString["list"])); //實作分頁 bookBL.Pages(Panel1, activePage, dataCount, Request.QueryString["type"], Request.QueryString["class_id"], Request.QueryString["list"]); //資料綁定 DataList1.DataSource = bookBL.bookList(Request.QueryString["type"], Request.QueryString["class_id"], Request.QueryString["list"], Convert.ToInt32(activePage)); DataList1.DataBind(); } catch (Exception ex) { ex.ToString(); } }
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(); } }