【发布时间】:2013-03-07 03:11:32
【问题描述】:
向下滚动到底部时,我正在尝试将新项目加载到电子商务网站。我正在做大部分工作,但它会加载相同的数据......我正在传递一个计数器(通过会话)来选择新行,但它不起作用。
这里是 jquery 代码...
function sendData() {
<% Session["count_of_rows_displayed"] = Convert.ToInt16(Session["count_of_rows_displayed"].ToString()) + 1; %>
alert('<%= Session["count_of_rows_displayed"].ToString() %>');
$.ajax(
{
type: "POST",
url: "insaat.aspx/GetData",
data: "{'number_of_rows':'" + <%= Session["count_of_rows_displayed"].ToString() %> +"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "true",
cache: "false",
success: function (msg) {
$("#myDiv").append(msg.d);
},
Error: function (x, e) {
alert("Some error");
}
});
}
这是网络方法
[WebMethod]
public static string GetData(String number_of_rows)
{
int no = Convert.ToInt16(number_of_rows);
string resp = string.Empty;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds = new DataSet();
int i = 0;
connection.Open();
adapter.SelectCommand = new SqlCommand("SELECT TOP " + (no*6) + " * FROM (SELECT TOP " + ((++no) * 6) + " * FROM Product ORDER BY id ASC) t ORDER BY id DESC", connection);
adapter.Fill(ds);
connection.Close();
for (i = 0; i <= ds.Tables[0].Rows.Count - 1 && i < 24; i++)
// build the data
connection.Close();
return resp;
}
我正在尝试增加会话并使用 jquery 传递它。但它不会增加会话。如何增加会话?
【问题讨论】:
-
也许这对你有帮助...aspsnippets.com/Articles/…