⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictionarylister.cs

📁 东软内部材料(四)asp等相关的教学案例 
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Web.UI.WebControls;

namespace WroxControls 
{

   public class ICollectionLister : WebControl, INamingContainer
											        // Step 3
   {

		ICollection _datasource;


		public ICollection DataSource
		{
			get { return _datasource; }
			set { _datasource = value; }
		}

		Style _headingStyle = new Style();

		public Style HeadingStyle
		{
			get{ return _headingStyle; }
		}

		Style _itemStyle = new Style();

		public Style ItemStyle
		{
			get{ return _itemStyle; }
		}

      protected override void CreateChildControls()
      {
			IEnumerator e;
			Label l;

			// Create the heading, using the specified user style

			l = new Label();
			l.ApplyStyle( _headingStyle );
			l.Text = "ICollection Lister Control";
			Controls.Add( l );

			// Create an label for each key/value pair in the collection

			if ( _datasource == null )
				throw new Exception("Control requires a data source");

			e = _datasource.GetEnumerator();

			while( e.MoveNext() )
			{
				l = new Label();
				l.ApplyStyle( _itemStyle );
				l.Text = "<BR>" + e.Current.ToString();
				Controls.Add( l );
			}
		}
   }
};

⌨️ 快捷键说明

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