Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize the number of rows displayed by DataList

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report