How to customize DataList to display the number of data rows

Source: Internet
Author: User

Copy codeThe 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 = "Activity 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. If LinqDataSource is used, the number of bound data rows cannot be limited.

Instead, select the data customized by using Linq to SQL in the background and bind it to Datalist.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.