Quantcast
Viewing all articles
Browse latest Browse all 7205

How to download files from a specific ASPxGridView's column


This example illustrates how to create a column whose cells are rendered as links with icons. Once the link is clicked, the file that corresponds to the current row starts downloading. Here is a downloading column's markup:

[ASPx]
<dx:GridViewDataColumnCaption="Doc"VisibleIndex="5"><DataItemTemplate><dx:ASPxButtonID="ASPxButton1"runat="server"OnInit="ASPxButton1_Init"AutoPostBack="False"RenderMode="Link"Text="Download"><ImageIconID="actions_download_16x16"/></dx:ASPxButton></DataItemTemplate></dx:GridViewDataColumn>

Note that we are using the common GridViewDataColumn Class with the ASPxButton Class which ASPxButton.RenderMode Property has the Link value (see also: ASPxButton - How to disable default appearance starting with 13.2 (display only an image)). This way, we can display an image. If you need only a link, it is sufficient to use the GridViewDataHyperLinkColumn Class. The ASPxButton's client-side Click event code is calculated dynamically in the server-side Init event handler. Here we redirect a web browser to the FileDownloadHandler.asxh handler (e.g., see ASP.NET Futures - Generating Dynamic Images with HttpHandlers gets Easier - Scott Hanselman) to obtain the corresponding file by a row key value and send this file to the browser.

NOTE: If you are only interested in end-user capabilities for file uploading and downloading, consider using our ASPxFileManager Class (e.g., see File Download).


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>