void DataBindToRepeater(int currentPage) { int id = Convert.ToInt32(Request.QueryString["id"]); string sql = "select * from Borrowbook where id='" + id + "'";//查询id下借阅信息 DataTable dt = new DataTable(); dt = myeditor.select(sql); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = dt.DefaultView; lbTotal.Text = pds.PageCount.ToString(); pds.CurrentPageIndex = currentPage - 1;//当前页数从零开始,故把接受的数减一 RptBook.DataSource = pds; RptBook.DataBind(); }
void DataBindToRepeater(int currentPage) { string id = Session["id"].ToString(); string sql = "select * from Borrowbook where id='" + id + "'"; //查询用户名下借阅信息 DataTable dt = new DataTable(); dt = change.select(sql); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = dt.DefaultView; lbTotal.Text = pds.PageCount.ToString(); pds.CurrentPageIndex = currentPage - 1; //当前页数从零开始,故把接受的数减一 RptBook.DataSource = pds; RptBook.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["name"].ToString() == " ") { Response.Write("<script>alert('尚未登录!');location='Login.aspx'</script>"); } try { string username = Session["name"].ToString(); string sql = "select * from login2 where username='******'"; DataTable dt = new DataTable(); dt = change.select(sql); RptBook.DataSource = dt; RptBook.DataBind(); } catch (Exception) { Response.Write("<script>alert('尚未登录!');location='Login.aspx'</script>"); } }
void DataBindToRepeater(int currentPage) { DataTable dt1 = new DataTable(); string book = Session["book"].ToString(); string sql = "select * from Book where bookname like'%" + book + "%' or author like'%" + book + "%'"; dt1 = myborrow.select(sql); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = dt1.DefaultView; lbTotal.Text = pds.PageCount.ToString(); pds.CurrentPageIndex = currentPage - 1;//当前页数从零开始,故把接受的数减一 RptBook.DataSource = pds; RptBook.DataBind(); }
protected void BtnFind_Click(object sender, EventArgs e) { string Author = TxtFind.Text.ToString(); if (RE.nobookname.IsMatch(Author)) { Response.Write("<script>alert('请输入合法字符');</script>"); } else { RptBook.Visible = true; string sql = "select * from librarybooks where Author like '%" + Author + "%'"; SqlConnection conn = new SqlConnection(str); DataTable dt = new DataTable(); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(sql, conn); da.Fill(dt); conn.Close(); //把查询出的数据放入datatable RptBook.DataSource = dt; RptBook.DataBind(); } }
void DataBindToRepeater(int currentPage) { string sql = "select * from Book"; DataTable dt = new DataTable(); dt = change.select(sql); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = dt.DefaultView; lbTotal.Text = pds.PageCount.ToString(); pds.CurrentPageIndex = currentPage - 1;//当前页数从零开始,故把接受的数减一 RptBook.DataSource = pds; RptBook.DataBind(); }