Exemplo n.º 1
0
		public void RegenerateColumns()
		{
			object ds = dataSource;
			if (ds is PagedDataSource)
				ds = ((PagedDataSource) dataSource).DataSource;

			DataTable dt;
			if (ds is DataView)
				dt = ((DataView) ds).Table;
			else if (ds is DataTable)
				dt = ((DataTable) ds);
			else if (ds == null)
				throw new ArgumentNullException("dataSource", "DataSource can't be null.");
			else
				throw new ArgumentException("DataSource type not supported: " + ds.GetType().FullName);
	
			Columns.Clear();
			foreach (DataColumn col in dt.Columns) 
			{
				if (this.PrimaryKey != col.ColumnName)
				{
					GridColumn gcol = new GridColumn();
					gcol.SourceDataColumn = col;
					gcol.ColumnIndex = this.Columns.Count;
					gcol.DataField = col.ColumnName;
					gcol.HeaderText = col.ColumnName;
					this.Columns.Add(gcol);
				}
			}
		}
		public int Add(GridColumn col)
		{
			return List.Add(col);
		}
Exemplo n.º 3
0
		protected virtual object GetValue(object obj, GridColumn col)
		{
			object val = DataBinderEx.Eval(obj, col.DataField);

			foreach (IDataFormatterPlugin plugin in plugins.Select(typeof(IDataFormatterPlugin)))
				val = plugin.Format(col, val);

			if (col.DataFormatString != null)
				val = String.Format(PluggableFormatProvider.Instance, col.DataFormatString, val);

			if (!col.AllowHtml)
				val = Server.HtmlEncode(Convert.ToString(val, CultureInfo.InvariantCulture));

			return val;
		}