代码
上一篇
create proc Prev
(
@ID
)
as
declare @Record int
set @Record = (select count(ID) from News where ID<@ID)
if @Record>0
begin
select top 1 ID from News where ID<@ID order by ID desc
end
else
begin
select max(ID) from News
end
下一篇
create proc Next
(
@ID
)
as
declare @Record int
set @Record = (select count(ID) from News where ID>@ID)
if @Record>0
begin
select top 1 ID from News where ID>@ID
end
else
begin
select min(ID) from News
end
aspnet 上一篇下一篇代码2010-03-02 16:43<div style="float: left; 316px; line-height: 25px; height: 25px; margin-left: 2px;">
下一篇:<asp:HyperLink ID="HyperLink1" runat="server">[HyperLink1]</asp:HyperLink>
</div>
<div style="float: right; 316px; line-height: 25px; height: 25px">
上一篇:<asp:HyperLink ID="HyperLink2" runat="server">[HyperLink2]</asp:HyperLink></div>
public void next()
{
string t_id = Request.QueryString["id"].ToString();
string sql = "select top 1 title,id from content where id>'" + t_id;
DataSet dr = xgl.databind(sql);
if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr = xgl.databind(sql).Tables[0].Rows[0];
this.HyperLink1.Text = SubStr(dr["title"].ToString(), 20);
this.HyperLink1.NavigateUrl = "e" + dr["id"].ToString() + ".aspx";
}
else
{
this.HyperLink1.Text = "没有下一篇!";
}
}
public void Pre()
{
string t_id = Request.QueryString["id"].ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
conn.Open();
SqlCommand sqlCmd1 = new SqlCommand("select top 1 title,id from content where id<'" + t_id + "'", conn);
SqlDataReader dr1 = sqlCmd1.ExecuteReader();
if (dr1.Read())
{
this.HyperLink2.Text = SubStr(dr1["title"].ToString(), 20);
this.HyperLink2.NavigateUrl = "e" + dr1["id"].ToString() + ".aspx";
}
else
{
this.HyperLink2.Text = "没有上一篇!";
}
sqlCmd1.Dispose();
conn.Close();
}