I am tryin to load new items to e-commerce website when scroll down to the bottom. I am doing most part of it but it gets the same data to load... I am passing a counter(via session) to select new rows but it doesnt work.
here is the jquery code...
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");
}
});
}
here is the webmethod
[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;
}
I am trying to increment session and pass it with jquery. But it doesnt increment the session. How can I get session incremented ?