码迷,mamicode.com
首页 > 其他好文 > 详细

焦点图的绑定

时间:2015-05-13 16:06:08      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

在aspx页面的代码

< div class="focus_images">
                < ul class="focus_ul">
                    <%= ViewState[ "FocusImages"] %>
                </ ul>
                < div class="dot"> <% = ViewState[ "FocusBtns" ] %> </div >
                < a class="prev btn" href="javascript:void(0);"></ a ><a class="next btn" href ="javascript:void(0);"></ a>
                <%= ViewState[ "FocusHdns"] %>
            </ div>
 
绑定后台的方法:
private void FocusImages()
        {
            //****************焦点图部分******************
            var _images = "" ;
            var _btns = "" ;
            var _hdns = "" ;
            DataSet ds = zzzsFocusImagesDAL .GetList(3, """addtime desc" );
            if (ds.Tables[0].Rows.Count > 0)
            {
                var index = 1;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    if (index == 1)
                    {
                        _images += "<li id=\"flash1\" style=\"display:block;\">" ;
                        _btns += "<span id=\"f1\" class=\"dq\" onclick=\"changeflash(1)\"></span>" ;
                    }
                    else
                    {
                        _images += string .Format("<li id=\"flash{0}\" style=\"display:block;\">" , index);
                        _btns += string .Format("<span id=\"f{0}\" class=\"no\" onclick=\"changeflash({0})\"></span>", index);
                    }
                    _images += string .Format("<a href=\"{0}\" target=\"_blank\" title=\"{2}\"><img src=\"{1}\" width=\"675\" height=\"276\" alt=\"{2}\"></a><em class=\"bgcolor1\"></em></li>" , row[ "linkurl"], row["imageurl" ], row[ "title"]);
                    //改变背景色
                    //_hdns += string.Format("<input type=\"hidden\" id=\"hdn{0}\" value=\"{1}\" />", index, row["BackGroundColor"]);
                    index++;
                }
 
            }
            ViewState[ "FocusImages" ] = _images;
            ViewState[ "FocusBtns" ] = _btns;
            ViewState[ "FocusHdns" ] = _hdns;
        }
 
        /// <summary>
        /// 查询zzzs_flash表
        /// </summary>
        /// <param name="Top"> 排行数 </param>
        /// <param name="strWhere"> 条件变量 </param>
        /// <param name="order"> 分组 </param>
        /// <returns> DataSet数据集 </returns>
        public static DataSet GetList( int Top, string strWhere, string order)
        {
            string strSql = string .Format( "SELECT TOP {0} * FROM zzzs_flash ", Top);
            if (!string .IsNullOrEmpty(strWhere))
                strSql += string .Format("WHERE {0}" , strWhere);
            if (!string .IsNullOrEmpty(order))
                strSql += string .Format(" order by {0}" , order);
            return DbHelperSQL .Query(strSql);
        }
 
其实只要清楚它的原理,循环出每一张就好了,希望对你有帮助。

焦点图的绑定

标签:

原文地址:http://www.cnblogs.com/liuyanpeng/p/4500499.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!