How to do datalist paging using linq to sql and datalist in asp 3.5?

泄露秘密 提交于 2019-12-25 04:14:30

问题


I'm using datalist in my application and i'm binding datalist with lisq to sql

dim db=new linqdatacontext(); var products=from p in db.products select p; datalist.datasource=products; datalist.databind();

now how can i do paging in my datalist?


回答1:


Use keywords Take and Skip

var products=from p in db.products select p 
             Skip NUMER_TO_START Take NUMBER_TO_TAKE

Very simple, consider there are 1000 rows of results in p, and Skip 50 means you are not going take results #1-#50, and it will give you results from #51, Take is simply how many records you need.



来源:https://stackoverflow.com/questions/1071812/how-to-do-datalist-paging-using-linq-to-sql-and-datalist-in-asp-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!