OmriN 0 Newbie Poster

Hi Everyone,

i've got a problem after opening CSV file to the client Side.

my application import data from the Client Side to the server, while it running i keep record of errors in DataTable Object and at the end of the process i export this DataTable into a CSV file which is prompt to the user at client Side.

now, after the user view this CSV file or saved it, the code just stop running which is crucial cause i still need to set some parameters.

this is my code ( more or less):

If ErrLogDT.Rows.Count > 0 Then
                tErr.ExportToSpreadsheet(ErrLogDT, "ErrorLog")
                
End If
 'this parameters i try to set after showing the Error Log
            RowCount.Value = "1"       
            CurrentState.Value = "False"



Public Sub ExportToSpreadsheet(ByVal tempDT As DataTable, ByVal name As String, ByVal connData As SqlConnection)
        Dim context As HttpContext = HttpContext.Current
        context.Response.Clear()
        For Each column As DataColumn In tempDT.Columns
            context.Response.Write(column.ColumnName + ",")
        Next
        context.Response.Write(Environment.NewLine)
        For Each row As DataRow In tempDT.Rows
            For i As Integer = 0 To tempDT.Columns.Count - 1
                context.Response.Write(row.Item(i).ToString().Replace(",", String.Empty) + ",")
            Next
            context.Response.Write(Environment.NewLine)
        Next
        context.Response.ContentType = "text/csv"
        context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".csv")
        context.Response.[End]()
    End Sub

Does anyone know why this happens?

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.