文章上下篇实例
文章上一篇:
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
protected void BindUp() //绑定上一条
{
int sortID =Convert.ToInt32( lab_sortID.Text.ToString());
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string query = "select top 1 min(id) as id,title from qbh_content where sort_id="+sortID+ " and id >" + id+"group by title order by id";
try
{
con.Open();
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
hyperUp.Text = dr["title"].ToString().Trim();
hyperUp.NavigateUrl = "NewsDetail.aspx?id=" + dr["id"].ToString() + "";
}
}
catch { }
finally
{
con.Close();
}
}
{
int sortID =Convert.ToInt32( lab_sortID.Text.ToString());
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string query = "select top 1 min(id) as id,title from qbh_content where sort_id="+sortID+ " and id >" + id+"group by title order by id";
try
{
con.Open();
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
hyperUp.Text = dr["title"].ToString().Trim();
hyperUp.NavigateUrl = "NewsDetail.aspx?id=" + dr["id"].ToString() + "";
}
}
catch { }
finally
{
con.Close();
}
}
文章下一篇:
代码
protected void BindDown()//绑定下一条
{
int sortID = Convert.ToInt32(lab_sortID.Text.ToString());
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string query = "select top 1 max(id) as id,title from qbh_content where sort_id=" + sortID + " and id <" + id + " group by title order by id desc";
SqlCommand cmd = new SqlCommand(query, con);
try
{
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
hyperDown.Text = dr["title"].ToString().Trim();
hyperDown.NavigateUrl = "NewsDetail.aspx?id=" + dr["id"].ToString() + "";
}
}
catch { }
finally
{
con.Close();
}
}
{
int sortID = Convert.ToInt32(lab_sortID.Text.ToString());
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string query = "select top 1 max(id) as id,title from qbh_content where sort_id=" + sortID + " and id <" + id + " group by title order by id desc";
SqlCommand cmd = new SqlCommand(query, con);
try
{
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
hyperDown.Text = dr["title"].ToString().Trim();
hyperDown.NavigateUrl = "NewsDetail.aspx?id=" + dr["id"].ToString() + "";
}
}
catch { }
finally
{
con.Close();
}
}