前台页面:
<div class="mtgz_prev_next">
<p>
<span class="textcolor6">上一篇:</span>
<asp:Label ID="lblPre" runat="server" Text=""></asp:Label>
</p>
<p>
<span class="textcolor6">下一篇: </span>
<asp:Label ID="lblNext" runat="server" Text=""></asp:Label>
</p>
</div>
后台代码:
protected void GetPreTitle()
{
if (!string.IsNullOrEmpty(NewsID))
{
int num = Convert.ToInt32(NewsID);
DataSet ds = bll.GetList("ID=" + (num - 1));
if (ds.Tables[0].Rows.Count > 0)
{
newsArr["PreTitle"] = ds.Tables[0].Rows[0]["Title"].ToString();
newsArr["PreID"] = num - 1;
lblPre.Text=" <a href=ljwm-mtgz-ny.aspx?ID=" + newsArr["PreID"].ToString() + ">" + newsArr["PreTitle"].ToString() + "</a>";
}
else
{
lblPre.Text ="已经是第一篇";
}
}
}
protected void GetNextTitle()
{
if (!string.IsNullOrEmpty(NewsID))
{
int num = Convert.ToInt32(NewsID);
DataSet ds = bll.GetList("ID=" + (num + 1));
if (ds.Tables[0].Rows.Count > 0)
{
newsArr["NextTitle"] = ds.Tables[0].Rows[0]["Title"].ToString();
newsArr["NextID"] = num + 1;
lblNext.Text = " <a href=ljwm-mtgz-ny.aspx?ID=" + newsArr["NextID"].ToString() + ">" + newsArr["NextTitle"].ToString() + "</a>";
}
else
{
lblNext.Text ="已经是最后一篇";
}
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。