if ($(window).scrollTop() == $(document).height() - $(window).height()) {
// 您的程式......
}
});
- Web Service -- https://dotblogs.com.tw/mis2000lab/archive/2008/09/26/webservice_1.aspx
- 資料分頁 -- 以下兩個範例都有提供 Youtube教學影片
- jQuery + Web Service 互動範例 -- https://dotblogs.com.tw/mis2000lab/archive/2015/05/19/jquery_ajax_web_service.aspx
)
using System.Data;
using System.Data.SqlClient;
using System.Web.Services; //*** Web Service 會用到 ***
using System.Web.Configuration;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) // 第一次執行
{ // 自己寫的副程式,從第一頁開始。
Repeater1.DataSource = MIS2000Lab_GetPageData(1);
Repeater1.DataBind();
}
}
// ***** 分頁。使用SQL指令進行分頁 *****
public static DataSet MIS2000Lab_GetPageData(int currentPage)
{
SqlConnection Conn = new SqlConnection("資料庫的連結字串");
String SqlStr = "Select * from Customers ORDER BY [CustomerID] ASC ";
SqlStr += " OFFSET @A ROWS FETCH NEXT 10 ROWS ONLY";
// 為了配合前端的jQeury,這裡的第一頁不可以是"零",需是一。程式改成 ((currentPage-1) * 10)
//==SQL 2012 指令的 Offset...Fetch。參考資料: http://sharedderrick.blogspot.tw/2012/06/t-sql-offset-fetch.html
SqlDataAdapter myAdapter = new SqlDataAdapter(SqlStr, Conn);
myAdapter.SelectCommand.Parameters.AddWithValue("@A", ((currentPage - 1) * 10));
DataSet ds = new DataSet();
myAdapter.Fill(ds, "Customers");
//-- 用來計算分頁的「總頁數」 ---
SqlCommand cmd = new SqlCommand("select Count(CustomerID) from Customers", Conn);
Conn.Open();
int myTotalCount = (int)cmd.ExecuteScalar();
DataTable dt = new DataTable("PageCount");
dt.Columns.Add("PageCount");
dt.Rows.Add();
dt.Rows[0][0] = myTotalCount;
ds.Tables.Add(dt);
if (Conn.State == ConnectionState.Open) {
Conn.Close();
Conn.Dispose();
}
return ds;
}
[WebMethod]
public static string GetCustomers(int pageIndex)
{
return MIS2000Lab_GetPageData(pageIndex).GetXml();
}
抱歉,因為程式碼貼上後,排版錯亂,只好貼圖!
或是來這裡,複製程式碼 -- http://mis2000lab.pixnet.net/blog/post/34529733-%E7%84%A1%E9%99%90%E4%B8%8B%E6%8B%89%E7%9A%84%E8%B3%87%E6%96%99%E5%91%88%E7%8F%BE%20(%E9%A1%9E%E4%BC%BCFaceBook%EF%BC%8C%E5%88%86%E9%A0%81%E6%95%88%E6%9E%9C)%20-%20jQuery%20+%20Web%20Service%20+%20Repeater%E6%8E%A7%E5%88%B6%E9%A0%85

下一篇文章: http://mis2000lab.blogspot.tw/2016/12/facebook-2.html
