ASP.NET GridView 怎么让数据库中的记录不全部显示出来 而是显示几条记录,不用分页
我数据库有8条记录,如何让这个只显示7条记录<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="F...
我数据库有8条记录,如何让这个只显示7条记录
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" GridLines=None
Height="207px" Width="175px" CssClass="test" PageSize="7" >
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="标题"
DataNavigateUrlFormatString="shownews.aspx?id={0}" DataTextField="标题">
<ItemStyle Wrap="False" />
</asp:HyperLinkField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HaixiConnectionString %>"
SelectCommand="SELECT * FROM [勤工俭学] ORDER BY [id] DESC"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
百度了一些 有些说是 select top 10 * from 表 不过我都不知道写在哪里 具体怎么写
最好是显示倒数7个 展开
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" GridLines=None
Height="207px" Width="175px" CssClass="test" PageSize="7" >
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="标题"
DataNavigateUrlFormatString="shownews.aspx?id={0}" DataTextField="标题">
<ItemStyle Wrap="False" />
</asp:HyperLinkField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HaixiConnectionString %>"
SelectCommand="SELECT * FROM [勤工俭学] ORDER BY [id] DESC"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
百度了一些 有些说是 select top 10 * from 表 不过我都不知道写在哪里 具体怎么写
最好是显示倒数7个 展开
展开全部
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HaixiConnectionString %>"
SelectCommand="SELECT top 7 * FROM [勤工俭学] ORDER BY [id] DESC"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
ConnectionString="<%$ ConnectionStrings:HaixiConnectionString %>"
SelectCommand="SELECT top 7 * FROM [勤工俭学] ORDER BY [id] DESC"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询