Get the App
SLTechnology News&Howtos  ›  Development  › 

How to customize the number of rows displayed by DataList

Shulou Source: shulou.com Published: 2022-06-03 05:42:09 11月18日 Update

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!

Tags: Data content articles instead code value information interests guys partners data sources more campus event scheduling knowledge industry information channels channels references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Redmi Docker MySQL