AllInWorld99 provides a reference manual covering many aspects of web programming, including technologies such as HTML, XHTML, CSS, XML, JavaScript, PHP, ASP, SQL,FLASH, jQuery, java, for loop, switch case, if, if else, for...of, for...in, for...each,while loop, blogger tips, blogger meta tag generator, blogger tricks, blogger pagination, client side script, html code editor, javascript editor with instant output, css editor, online html editor, materialize css tutorial, materialize css dropdown list,break, continue statement, label,array, json, get day and month dropdown list using c# code, CSS button,protect cd or pendrive from virus, cordova, android example, html and css to make android app, html code play,telerik show hide column, Transparent image convertor, copy to clipboard using javascript without using any swf file, simple animation using css, SQL etc. AllInWorld99 presents thousands of code examples (accompanied with source code) which can be copied/downloaded independantly. By using the online editor provided,readers can edit the examples and execute the code experimentally.


SQL pagination example

     When we are bind the grid with pagination should we need to control both side (client side and server side).
     For example if we have 100 rows and need to display 20 rows per page, so we should calculate the pagination from total count and limit, total count will get from procedure. Like below

select * from( 
select row_number() over(order by RegisterNumber desc) as RowNum,* from(
select COUNT(*) over() as Totalcount,EmployeeName,RegisterNumber from clg_tb_student
)x)xx where xx.RowNum>@startIndex and  xx.RowNum<=@endIndex

     In the above procedure, If the @startIndex is 0 and @endIndex is 10 then the procedure will return only 10 records and the count column field will tell you the total count of your records.

SQL Pagination













Easy method to applying your existing procedure

     consider the below is your existing procedure
select * from .............

Remove the select and just copy and paste the following code to above of your existing code.
select * from(  
select row_number() over(order by RegisterNumber desc) as RowNum,* from(
select COUNT(*) over() as count,

select * from(  
select row_number() over(order by RegisterNumber desc) as RowNum,* from(
select COUNT(*) over() as count,
* from .............

Copy and paste the following code to below of the modified code
)x)xx where xx.RowNum>@startIndex and  xx.RowNum<=@endIndex

select * from(  
select row_number() over(order by RegisterNumber desc) as RowNum,* from(
select COUNT(*) over() as count,
* from .............
)x)xx where xx.RowNum>@startIndex and  xx.RowNum<=@endIndex

0 comments:

Post a Comment

Total Pageviews