zoukankan      html  css  js  c++  java
  • .net中点击button按钮显示下一条记录(上一条 下一条)

    /// <summary>
       
    /// 取出前后新闻,产生连接,如果前后都有则占2行.
       
    /// </summary>
       
    /// <param name="articleid">目前记录id</param>
       
    /// <returns></returns>
        public string _4S_article_link(string articleid, string page)
        {
            StringBuilder str
    = new StringBuilder("");
            con.SetDefaultConnection(constr);
           
    string sql = "SELECT classname FROM db_article WHERE (articleid = @articleid)";
            SqlParameter[] prams
    = new SqlParameter[1];
            prams[
    0] = new SqlParameter("@articleid", articleid);
            DataRow row
    = con.Row(sql, prams);
           
    string classname = row["classname"].ToString();
            sql
    = "SELECT TOP 1 articleid FROM db_article WHERE (articleid < @articleid) AND (classname = '" + classname + "') ORDER BY articleid DESC";
            prams[
    0].ParameterName = "@articleid";
            prams[
    0].Value = articleid;

            row
    = con.Row(sql, prams);
           
    if (row != null)
            {
                str.Append(
    "<a href='"+page+"?id=" + classname.Substring(5) +"&articleid=");
                str.Append(row[
    "articleid"].ToString());
                str.Append(
    "'><span style='color: #000099'>上一条");
                str.Append(
    "</span></a>");
            }
            sql
    = "SELECT TOP 1 articleid FROM db_article WHERE (articleid > @articleid) AND (classname = '" + classname + "') ORDER BY articleid";
            row
    = con.Row(sql, prams);
           
    if (row != null)
            {
                str.Append(
    "&nbsp;&nbsp;&nbsp;&nbsp;<a href='"+page+"?id=" + classname.Substring(5) + "&articleid=");
                str.Append(row[
    "articleid"].ToString());
                str.Append(
    "'><span style='color: #000099'>下一条");
                str.Append(
    "</span></a>&nbsp;&nbsp;&nbsp;&nbsp;");
            }
           
    else
                str.Append(
    "&nbsp;&nbsp;&nbsp;&nbsp;");
           
    return str.ToString();
        }
  • 相关阅读:
    Java实现直接插入查找
    CSS hack常用方案(摘选)
    输入一个字符串,去掉重复的字符,并按ASCII值排序-华为机试
    git操作github
    简单记录下idea上配置spring
    mysql国内镜像下载网址
    tomcat启动不成功(点击startup.bat闪退)的解决办法
    Encode and Decode TinyURL
    leetcode 4Sum II
    leetcode two sum
  • 原文地址:https://www.cnblogs.com/liufei88866/p/1293515.html
Copyright © 2011-2022 走看看