aggregategrouplist.cs

来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 105 行

CS
105
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Controls;

namespace CommunityServer.Blogs.Controls
{
	/// <summary>
	/// Summary description for AggregateGroupList.
	/// </summary>
	public class AggregateGroupList : WeblogBaseTemplatedWebControl
	{
		public AggregateGroupList()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        ResourceControl Title = null;
	    Repeater AggList = null;


        /// <summary>
        /// Property ResourceNameTitle (string)
        /// </summary>
        public string ResourceNameTitle
        {
            get
            {
                return ViewState["ResourceNameTitle"] as string;
            }
            set
            {  ViewState["ResourceNameTitle"] = value; }
        }

        /// <summary>
        /// Property UrlFormat (string)
        /// </summary>
        public string UrlFormat
        {
            get{  return ViewState["UrlFormat"] as string;}
            set{  ViewState["UrlFormat"] = value; }
        }

        public override void DataBind()
        {
            base.DataBind ();

            if(DataSource != null)
            {
                AggList.DataSource = DataSource;
                AggList.DataBind();
            }

            this.Title.ResourceName = ResourceNameTitle;
            
        }

        private object _dataSource;
        /// <summary>
        /// Property DataSource (object)
        /// </summary>
        public object DataSource
        {
            get {  return this._dataSource; }
            set {  this._dataSource = value; }
        }


	    protected override void AttachChildControls()
	    {
	        Title = FindControl("Title") as ResourceControl;
            AggList = FindControl("AggList") as Repeater;
            AggList.ItemDataBound +=new RepeaterItemEventHandler(AggList_ItemDataBound);

        }

        private void AggList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Group g = e.Item.DataItem as Group;
                if(g != null)
                {
                    HyperLink aggLink = e.Item.FindControl("AggLink") as HyperLink;
                    if(aggLink !=null)
                    {
                        aggLink.Text = g.Name;
						
                        aggLink.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl(UrlFormat,g.GroupID);
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?