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.