Export a datagrid to csv

A

Amirallia

Hello

Here is nmy code to export a datagrid to csv file :
For lLigne = 0 To Me.dg1.Items.Count - 1
For lColonne = 0 To Me.dg1.Items(lLigne).Cells.Count - 2
If Me.dg1.Items(lLigne).Cells(lColonne).Text = " " Then
strValeur = ""
Else
strValeur = Me.dg1.Items(lLigne).Cells(lColonne).Text
End If

sbrHTML.Append(strValeur & Separator)
Next

sbrHTML.Append(ControlChars.NewLine)
Next

lTextCSV = sbrHTML.ToString
myByteArray = System.Text.Encoding.Default.GetBytes(lTextCSV)
Response.ClearHeaders()
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" &
"xxxx.csv")
Response.ContentType = "text/csv"
Response.BinaryWrite(myByteArray)
Response.End()

When I click on a button, it displays the download dialog box and all
is ok on my computer, but on my Laptop, it doesn't display the download
dialog box!!!!

Any idea ?

There is something in my Laptop's browser(IE) to change ?
 
W

Winista

Popup blocker...also look at top of document window in browser and see if
there a yellowish bar asking for permission to download file.
 
A

Amirallia

No, nothing is blocked!

The page directy displays with the results of the export
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Export to CSV problem 2
export to PDF problem 2
Export datagrid to excel file 3
Export To Excel 1
export dataset to excel 5
export to excel 0
export to excel with special characters 2
CSV export to new Window? 1

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top