Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
How do you download a file to the client? I've used the streamwriter but as far as I can tell it is only for saving files to the server not the client. I know there's a way because I've downloaded things from this forum.
Posted
Here's the thing. I have a dataset that contains let's say 210 records that I'm displaying in a grid with the paging set at 25. I want the user to be able to save the entire dataset to there machine. Also, I would prefer it if the user didn't have to leave the page in order do download the file.
Posted

What format you want the user to download? you can use your method to save the file in server, then use "Response.Redirect" to send it to client.

 

Logically it should works...:)

Posted

I had the same problem. My resolution was to extract the datagrid content to excel, thus allowing the users to save and change the data as required.

 

Try this sample on pageload:

 

' Set the content type to Excel.

Response.ContentType = "application/vnd.ms-excel"

' Remove the charset from the Content-Type header.

Response.Charset = ""

' Turn off the view state.

Me.EnableViewState = False

Dim tw As New System.IO.StringWriter

Dim hw As New System.Web.UI.HtmlTextWriter(tw)

' Get the HTML for the control.

DataGrid1.RenderControl(hw)

' Write the HTML back to the browser.

Response.Write(tw.ToString())

' End the response.

Response.End()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...