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

📄 expandcommandcolumn.cs

📁 该控件主要实现嵌套联动表格 为主副表联动形式
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI.WebControls; 

namespace MsdnMag
{
	public class ExpandCommandColumn : DataGridColumn
	{
		public ExpandCommandColumn()
		{
			ExpandText = "+";
			CollapseText = "-";
		}


		// **********************************************************
		// Gets or sets the text for the item used to expand
		public string ExpandText 
		{
			get {return Convert.ToString(ViewState["ExpandText"]);}
			set {ViewState["ExpandText"] = value;}
		}
		// **********************************************************

		// **********************************************************
		// Gets or sets the text for the item used to collapse
		public string CollapseText 
		{
			get {return Convert.ToString(ViewState["CollapseText"]);}
			set {ViewState["CollapseText"] = value;}
		}
		// **********************************************************

		// **********************************************************
		// Initializes the cells in the column
		public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType) 
		{
			base.InitializeCell(cell, columnIndex, itemType);
		}
		public void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType, bool collapsed) 
		{
			base.InitializeCell(cell, columnIndex, itemType);

			if (itemType == ListItemType.Item ||
				itemType == ListItemType.AlternatingItem) 
			{
				LinkButton link = new LinkButton();
				link.CommandName = "Expand";

				if (collapsed)
					link.Text = this.CollapseText;
				else
					link.Text = this.ExpandText;

				link.CausesValidation = false;
				cell.Controls.Add(link);
			}
		}
		// **********************************************************
	}
}

⌨️ 快捷键说明

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