现在的位置: 首页 > 综合 > 正文

文章上下篇实例

2012年11月29日 ⁄ 综合 ⁄ 共 1564字 ⁄ 字号 评论关闭

 

文章上一篇:

代码

    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();
        }
    }

 

 

文章下一篇:

代码

 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();
        }
    } 

 

 

抱歉!评论已关闭.