Tips for data binding on Web pages

Source: Internet
Author: User

During Development today, I encountered a topic requirement to be displayed. I used two DataGrid to bind one topic,

The Database Number of the "Inside medicine" column is: category1 = 1, category2 = 2.

On the left, I used DataGrid1 to help: the data presented is the TOP 4 records in the "medical insider" column.

String str1 = "select top 4 title from NewsInfo where category1 = 1 and category2 = 2 order by id desc ";
DataGrid1.DataSource = sqlBase. ExecuteDataView (str1 );
DataGrid1.DataBind ();


On the right side, I used DataGrid2 to help: the data presented is the last four of the TOP eight digits in the "medical insider" column.

String str1 = "select top 4 title from NewsInfo where id
Not in (select top 4 id from NewsInfo where category1 = 1 and category2 = 2
Order by id desc) and category1 = 1 and category2 = 2 order by id desc ";
DataGrid1.DataSource = sqlBase. ExecuteDataView (str1 );
DataGrid1.DataBind ();

In this way, the data of a column can be displayed in two or more places on the page, and the latest records can be displayed without repeating, the key is not in () in SQL (). This is what I have learned. I hope you can correct it.


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.