视频列表

 <asp:ListView ID="listSubjects" runat="server" style="top: 0px; left: 0px" >
            <LayoutTemplate> 
             <div id="listcontent">     
             <asp:PlaceHolder ID="itemPlaceHolder" runat="server"/>
             </div>      
            </LayoutTemplate>           
            <ItemTemplate>           
                <div class="listpro">
                <a href='<%# Eval("LinkURL") %>'><%# Eval("Title") %></a>               
                </div>       
            </ItemTemplate>
            <EmptyDataTemplate >        
            </EmptyDataTemplate>           
        </asp:ListView>

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    this.listSubjects.DataSource = this.GetVideoList(ListName, ShowCount);
                    this.listSubjects.DataBind();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

        private List<ActionInfo> GetVideoList(string listName, int displayCount)
        {
            List<ActionInfo> infoList = new List<ActionInfo>();

            SPWeb web = SPContext.Current.Web;
            SPList list = web.GetList(String.Format("{1}/Lists/{0}", listName,web.Url));

            SPQuery query = new SPQuery();
            query.Query = String.Format("<OrderBy><FieldRef Name=\"ID\" Ascending=\"False\" /></OrderBy>");

            if (displayCount > 0)
            {
                query.RowLimit = (uint)displayCount;
            }

            SPListItemCollection colls = list.GetItems(query);

            string displayPage = list.DefaultDisplayFormUrl + "?ID={0}";

            SPField fldSummary = list.Fields.GetField("注释");
            SPField fldLinkPIC = list.Fields.GetField("缩略图");
   
            foreach (SPListItem item in colls)
            {
                ActionInfo info = new ActionInfo();
                info.ID = item.ID;
                info.Title = item["Title"].ToString();
                info.Summary = UtilityPlus.GetItemString(item[fldSummary.InternalName]);
                info.LinkURL = String.Format(displayPage, item.ID);
                info.LinkPIC = this.GetItemString(item[fldLinkPIC.InternalName]);
                info.CreatedAt = UtilityPlus.GetItemDateTime(item["Modified"]);
                infoList.Add(info);
            }

            return infoList;
        }

        public string GetItemString(object value)
        {
            if (value == null)
                return "/_layouts/images/movies.png";
            else
                return value.ToString();
        }
     

posted @ 2013-05-08 18:00  717806198  阅读(162)  评论(0编辑  收藏  举报