Posted on: 2/11/2015 5:17:42 PM | Views : 519

I used this code to paginate my results :
SqlConnection con = new SqlConnection(cs); SqlCommand cmd = new SqlCommand("SELECT * FROM tbl_news OFFSET @offset ROWS FETCH NEXT 10 ROWS ONLY ", con); SqlCommand cmdCount = new SqlCommand("SELECT COUNT(*) FROM tbl_news ", con); if (Request.QueryString["page"] != null) { cmd.Parameters.AddWithValue("@offset", Convert.ToInt32(Request.QueryString["page"]) * 10); } else { cmd.Parameters.AddWithValue("@offset", 0); } DataTable dt = new DataTable(); int recCunt = 0; using (con) { using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); con.Open(); recCun ...

Go to the complete details ...