GridAttachmentColumn provides an easy way to quickly setup download/upload functionality for files stored in binary form in your database. The column binds to a separate data source control that retrieves the actual binary data from your database, providing data key values from the main RadGrid data source to the SQL SELECT query returning the binary data.
To set up GridAttachmentColumn, a minimum collection of properties need to be set:
Additionally, GridAttachmentColumn provides the following properties for extented customization:
The download button fires RadGrid's ItemCommand event with command name DownloadAttachment that can be intercepted to modify the download properties, or manually download the attachment. The event can also be fired from code either on the server, or on the client using GridDataItem.FireCommandEvent() or GridTableView.fireCommand() methods, respectively.
In edit mode, GridAttachmentColumn provides a RadUpload control that can be used to upload and save files in the database. A grid column editor of type GridAttachmentColumnEditor gives you access to the RadUpload control back on the server. A note here is that the uploaded binary data is not automatically extracted using GridTableView.ExtractValuesFromItem(). This also means that no file data will be automatically saved to the column's data source even when automatic data source operations are set up for RadGrid.
Finally, due to the limitations of the javascript XmlHttpRequest object used for AJAX, to download or upload attachments, AJAX needs to be temporarily disabled, so that the page performs a full postback. When downloading, RadGrid's client-side OnCommand event can be used to intercept a download action and disable AJAX, while for uploads, we use the approach demonstrated in the RadGrid and RadUpload integration demo.
For additional information on GridAttachmentColumn, please refer to the respective section in the RadGrid column types topic from the online documentation.
www.telerik.com | Terms of Use | Contact Us