Ejemplo n.º 1
0
        /// <summary>
        /// 输出友情链接
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="orderby">排序条件</param>
        /// <returns></returns>
        public static string ViewImgList(int top, string strWhere, string orderby)
        {
            DtCms.BLL.Links bll    = new DtCms.BLL.Links();
            StringBuilder   strTxt = new StringBuilder();
            DataSet         ds     = bll.GetList(top, strWhere, orderby);

            //如果记录存在
            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    if (Convert.ToInt32(dr["IsImage"]) == 1)
                    {
                        strTxt.Append("<li>");
                        strTxt.Append("<a target=\"_blank\" href=\"" + dr["WebUrl"] + "\">");
                        strTxt.Append("<img border=\"0\" src=\"" + dr["ImgUrl"] + "\" alt=\"" + dr["Title"].ToString() + "\" />");
                        strTxt.Append("</a>");
                        strTxt.Append("</li>\n");
                    }
                    else
                    {
                        strTxt.Append("<a target=\"_blank\" href=\"" + dr["WebUrl"] + "\">");
                        strTxt.Append(dr["Title"].ToString());
                        strTxt.Append("</a>" + "&nbsp;&nbsp;");
                    }
                }
            }
            return(strTxt.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 绑定Repeater控件数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Link_List_DataBind(object sender, EventArgs e)
        {
            Repeater _rpt = sender as Repeater;

            if (_rpt == null)
            {
                return;
            }
            DtCms.BLL.Links bll = new DtCms.BLL.Links();
            //绑定数据
            if (_rpt.PageSize > 0)
            {
                _rpt.DataSource = bll.GetPageList(_rpt.PageSize, _rpt.PageIndex, _rpt.Where, "SortId asc,AddTime desc");
            }
            else
            {
                _rpt.DataSource = bll.GetList(_rpt.Top, _rpt.Where, "SortId asc,AddTime desc");
            }
            _rpt.DataBind();
        }