New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

When you have attachments saved in your data source as a blob of binary data, GridAttachmentColumn provides you an easy way to upload to and download straight from your data source. In normal mode, GridAttachmentColumn displays a button to download the attachment associated with the respective data record. In edit mode, a RadUpload is provided for the user to upload an attachment into the data source.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class GridAttachmentColumn : GridEditableColumn, IStateManager, IComparable, IGridEditableColumn, IGridDataColumn

Inheritance: objectGridColumnGridEditableColumnGridAttachmentColumn

Implements: IComparableIGridDataColumnIGridEditableColumnIStateManager

Inherited Members GridEditableColumn.SetDefaultColumnEditor(IGridColumnEditor)GridEditableColumn.GetEditableColumn()GridEditableColumn.ConvertValueIfEmpty(string)GridEditableColumn.GetActiveDataField()GridEditableColumn.ColumnEditorIDGridEditableColumn.MobileEditorGridEditableColumn.CurrentColumnEditorGridEditableColumn.InnerColumnEditorGridEditableColumn.ColumnEditorGridEditableColumn.ConvertEmptyStringToNullGridEditableColumn.UseNativeEditorsInMobileModeGridEditableColumn.DefaultInsertValueGridEditableColumn.ReadOnlyGridEditableColumn.InsertVisiblityModeGridEditableColumn.ForceExtractValueGridEditableColumn.AllowSortingGridEditableColumn.SortableGridEditableColumn.AllowFilteringGridColumn.Initialize()GridColumn.InitializeCell(TableCell, int, GridItem)GridColumn.ShouldSerializeFilterImageUrl()GridColumn.ShouldSerializeSortAscImageUrl()GridColumn.ShouldSerializeSortDescImageUrl()GridColumn.RefreshCurrentFilterValue(GridFilteringItem, string)GridColumn.RefreshCurrentFilterValue(GridFilteringItem)GridColumn.SetCurrentFilterValueToControl(TableCell)GridColumn.GetCurrentFilterValueFromControl(TableCell)GridColumn.EvaluateFilterExpression(GridFilteringItem)GridColumn.EvaluateFilterExpression()GridColumn.FunctionTakesNoArguments(GridKnownFunction)GridColumn.SetupFilterControls(TableCell)GridColumn.GetFilterFunctionsList(GridFilterListOptions, ArrayList)GridColumn.PrepareCell(TableCell, GridItem)GridColumn.LoadViewState(object)GridColumn.OnColumnChanged()GridColumn.SaveViewState()GridColumn.TrackViewState()GridColumn.ResetCurrentFilterValue(GridFilteringItem)GridColumn.ResetCurrentFilterValue()GridColumn.GetDefaultGroupByExpression()GridColumn.IsUniqueName(string)GridColumn.GenerateUniqueNameBase(string)GridColumn.TrySetOnClientClickScript(Control, GridItem, string, params string[])GridColumn.UpdateUniqueNameIfDefault(string)GridColumn.GetCustomPropertyDataFields(object)GridColumn.HeaderTooltipGridColumn.HeaderAbbrGridColumn.HeaderAxisGridColumn.SortedBackColorGridColumn.CurrentFilterValueGridColumn.AndCurrentFilterValueGridColumn.ColumnGroupNameGridColumn.SelectedGridColumn.SelectableGridColumn.CurrentFilterFunctionGridColumn.AndCurrentFilterFunctionGridColumn.FilterDelayGridColumn.ExportableGridColumn.EnableHeaderContextMenuGridColumn.ShowFilterIconGridColumn.FilterListOptionsGridColumn.AutoPostBackOnFilterGridColumn.FilterImageToolTipGridColumn.FilterControlToolTipGridColumn.EditorControlToolTipGridColumn.FilterImageUrlGridColumn.SortAscImageUrlGridColumn.SortDescImageUrlGridColumn.DataTypeNameGridColumn.ListOfFilterValuesGridColumn.FilterTemplateGridColumn.TableViewSpecificStateGridColumn.DesignModeGridColumn.FooterStyleGridColumn.FooterTextGridColumn.HeaderImageUrlGridColumn.HeaderStyleGridColumn.HeaderTextGridColumn.IsTrackingViewStateGridColumn.ItemStyleGridColumn.OwnerGridColumn.SortExpressionGridColumn.GroupByExpressionGridColumn.ViewStateGridColumn.ShowSortIconGridColumn.ShowNoSortIconGridColumn.VisibleGridColumn.DisplayGridColumn.OwnerIDGridColumn.OwnerGridIDGridColumn.ResizableGridColumn.ReorderableGridColumn.GroupableGridColumn.ColumnTypeGridColumn.HeaderButtonTypeGridColumn.OrderIndexGridColumn.IsDefaultUniqueNameGridColumn.EditFormColumnIndexGridColumn.UniqueNameGridColumn.EditFormHeaderTextFormatGridColumn.DataTypeGridColumn.FilterControlWidthGridColumn.FilterControlAltTextGridColumn.FilterCheckListWebServiceMethodGridColumn.FilterCheckListEnableLoadOnDemandobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

C#
public GridAttachmentColumn()

Properties

Gets or sets an array of file extensions that are allowed for uploading.

C#
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(GridStringArrayConverter))]
public string[] AllowedFileExtensions { get; set; }

Gets or sets the name of the data field from the column's data source where the binary attachment data is stored.

C#
public virtual string AttachmentDataField { get; set; }

Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, that uniquely identify an attachment from the column's data source

C#
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(GridStringArrayConverter))]
public virtual string[] AttachmentKeyFields { get; set; }
Property Value:

A string, representing a comma-separated enumeration of DataFields from the data source, which form the unique key identifying an attachment from the column's data source

Gets or sets the CssClass of the button

C#
public virtual string ButtonCssClass { get; set; }

Gets or sets a value indicating the type of the download button that will be rendered. The type should be one of the specified by the GridButtonColumnType enumeration.

C#
public virtual GridButtonColumnType ButtonType { get; set; }
LinkButtonRenders a standard hyperlink button.
PushButtonRenders a standard button.
ImageButtonRenders an image that acts like a button.

A string, specifying the ID of the datasource control, which will be used to retrieve binary data of the attachment.

C#
public string DataSourceID { get; set; }
Property Value:

A string, specifying the ID of the datasource control, which will be used to retrieve binary data of the attachment.

Gets or sets a value from the specified datasource field. This value will then be displayed in the GridAttachmentColumn.

C#
public virtual string DataTextField { get; set; }

Use the DataTextField property to specify the field name from the data source to bind to the Text property of the buttons in the GridAttachmentColumn object. Binding the column to a field instead of directly setting the Text property allows you to display different captions for the buttons in the GridAttachmentColumn by using the values in the specified field.

Tip: This property is most often used in combination with DataTextFormatString Property.

Example:
cs-api-definition
[ASPX/ASCX]<br/><br/><radg:RadGrid id=<font class="string">"RadGrid1"</font> runat=<font class="string">"server"</font>><br/>  <MasterTableView AutoGenerateColumns=<font class="string">"False"</font>><br/>    <Columns><br/>      <radg:GridAttachmentColumn HeaderText=<font class="string">"Customer ID"</font><font color="red">DataTextField=<font class="string">"CustomerID"</font></font><br/><font color="red">DataTextFormatString=<font class="string">"Edit Customer {0}"</font></font> ButtonType=<font class="string">"LinkButton"</font> UniqueName=<font class="string">"ButtonColumn"</font>><br/>     </radg:GridAttachmentColumn>

Gets or sets the string that specifies the display format for the caption in each button.

C#
public virtual string DataTextFormatString { get; set; }

Use the DataTextFormatString property to provide a custom display format for the caption of the buttons in the GridAttachmentColumn.

Note: The entire string must be enclosed in braces to indicate that it is a format string and not a literal string. Any text outside the braces is displayed as literal text.

Example:
C#
[ASPX/ASCX]<br/><br/><radg:RadGrid id=<font color="black"><font class="string">"RadGrid1"</font> runat=<font class="string">"server"</font>><br/>  <MasterTableView AutoGenerateColumns=<font class="string">"False"</font>><br/>    <Columns><br/>      <radg:GridAttachmentColumn HeaderText=<font class="string">"Customer ID"</font></font><font color="red">DataTextField=<font class="string">"CustomerID"</font><br/>DataTextFormatString=<font class="string">"Edit Customer {0}"</font></font> ButtonType=<font class="string" color="black">"LinkButton"</font> UniqueName=<font color="black"><font class="string">"ButtonColumn"</font>><br/>     </radg:GridAttachmentColumn></font>

Gets or sets the file name of the attachment.

C#
public virtual string FileName { get; set; }

Gets or sets the name of the field bound to the file name of the attachment.

C#
public virtual string FileNameTextField { get; set; }

Gets or sets the format string applied to the value bound to the FileNameTextField property

C#
public virtual string FileNameTextFormatString { get; set; }

Gets or sets a value indicating the URL for the image that will be used in a Image button. ButtonType should be set to ImageButton.

C#
public virtual string ImageUrl { get; set; }

This property is supposed for developers of new grid columns. It gets whether a column is currently ReadOnly. The ReadOnly property determines whether a column will be editable in edit mode. A column for which the ReadOnly property is true will not be present in the automatically generated edit form.

C#
public override bool IsEditable { get; }
Property Value:

A boolean value, indicating whether a specific column is editable.

Overrides: GridColumn.IsEditable

Gets or sets the maximum allowed size (in bytes) of the uploaded attachment.

C#
public int MaxFileSize { get; set; }

Gets or sets a value indicating the text that will be shown for a button.

C#
public virtual string Text { get; set; }

Gets or sets a value indicating what type of upload control will be initialized during edit. (Default value = RadUpload)

C#
public virtual GridUploadControlType UploadControlType { get; set; }

Methods

C#
protected virtual string ClientClickScript(string commandName, string commandArgument)
Parameters:commandNamestringcommandArgumentstringReturns:

string

Creates a copy of the current column.

C#
public override GridColumn Clone()
Returns:

GridColumn

Overrides: GridColumn.Clone()

Note: When implementing/overriding this method be sure to call the base member or call CopyBaseProperties to be sure that all base properties will be copied accordingly

C#
protected override void ColumnEditorChange(IGridColumnEditor newValue)
Parameters:newValueIGridColumnEditor

Overrides: GridEditableColumn.ColumnEditorChange(IGridColumnEditor)

C#
protected override void CopyBaseProperties(GridColumn fromColumn)
Parameters:fromColumnGridColumn

Overrides: GridEditableColumn.CopyBaseProperties(GridColumn)

C#
protected override IGridColumnEditor CreateDefaultColumnEditor()
Returns:

IGridColumnEditor

Overrides: GridEditableColumn.CreateDefaultColumnEditor()

Extracts the values from the editedItem and fills the names/values pairs for each data-field edited by the column in the newValues dictionary.

C#
public override void FillValues(IDictionary newValues, GridEditableItem editableItem)
Parameters:newValuesIDictionary

dictionary to fill. This param should not be null (Nothing in VB.NET)

editableItemGridEditableItem

the GridEditableItem to extract values from

Overrides: GridEditableColumn.FillValues(IDictionary, GridEditableItem)

C#
protected override string GenerateUniqueName()
Returns:

string

Overrides: GridColumn.GenerateUniqueName()

C#
protected override string GetFilterDataField()
Returns:

string

Overrides: GridColumn.GetFilterDataField()

This method returns true if the column is bound to the specified field name.

C#
public override bool IsBoundToFieldName(string name)
Parameters:namestring

The name of the DataField, which will be checked.

Returns:

bool

Overrides: GridColumn.IsBoundToFieldName(string)

C#
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
protected virtual void OnCellDataBound(object sender, GridCellDataBoundEventArgs args)
Parameters:senderobjectargsGridCellDataBoundEventArgs

Get value based on the current IsEditable state, item edited state and ForceExtractValue setting.

C#
public override bool ShouldExtractValues(GridEditableItem item)
Parameters:itemGridEditableItem

item to check to extract values from

Returns:

bool

Overrides: GridEditableColumn.ShouldExtractValues(GridEditableItem)

This method should be used in case you develop your own column. It returns true if the column supports filtering.

C#
public override bool SupportsFiltering()
Returns:

bool

Overrides: GridColumn.SupportsFiltering()