How to customize the number of rows displayed by DataList
This article mainly introduces how to customize DataList to display the number of rows of data, the article is very detailed, has a certain reference value, interested friends must read it!
The code is as follows:
PEAEWebSiteDataContext context = new PEAEWebSiteDataContext ()
Var p = from n in context.tb_News
Where n.cname = "Campus Information"
Select n
Var pp = p.OrderByDescending (tb_News= > tb_News.issuedate) .Take (1); var p1 = from n in context.tb_News
Where n.cname = "event schedule"
Select n
Var pp1 = p1.OrderByDescending (tb_News= > tb_News.issuedate) .take (1)
DataList1.DataSource = pp
DataList2.DataSource = pp1
DataList1.DataBind ()
DataList2.DataBind ()
The data source is dbml, and if you usually use LinqDataSource, the number of data rows bound cannot be limited.
Instead, select data customized by Linq to Sql in the background, and then bind it to Datalist.
The above is all the contents of the article "how to customize the number of rows of data displayed by DataList". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!