The message received from the server could not be parsed. Common causes for this error when the response is modifiedy by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'Sample ID First Crop'.
What I am trying to do from an ASP.Net (3.5) with AJAX update panel is when the user selects 'Export to Excel and presses the button. Here is the code. If there is another/better way to do this please advise. This code I inherited.
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=mySubmission.xls")
Response.Charset = "UTF-8"
Response.ContentType = "application/vnd.xls"
' getting heading
Dim strValues As String = ""
For ilcv As Integer = 1 To gvSamples.HeaderRow.Cells.Count - 2
strValues = strValues & gvSamples.HeaderRow.Cells(ilcv).Text & Chr(9)
Next
strValues = strValues & Chr(13)
'read data from gridView
For iLcv As Integer = 0 To gvSamples.Rows.Count - 1
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(1).FindControl("txtSampleID"), TextBox).Text & Chr(9)
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(3).FindControl("ddlFirstCode"), DropDownList).Text & Chr(9)
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(5).FindControl("ddlSecondCode"), DropDownList).Text & Chr(9)
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(6).FindControl("txtTonsAcre"), TextBox).Text & Chr(9)
If CType(gvSamples.Rows(iLcv).Cells(7).FindControl("ddlLimeMonth"), DropDownList).Text <> "Please select:" Then
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(7).FindControl("ddlLimeMonth"), DropDownList).Text & Chr(9)
Else
strValues = strValues & Chr(9)
End If
If CType(gvSamples.Rows(iLcv).Cells(8).FindControl("ddlLimeYear"), DropDownList).Text <> "Please select:" Then
strValues = strValues & CType(gvSamples.Rows(iLcv).Cells(8).FindControl("ddlLimeYear"), DropDownList).Text & Chr(9)
Else
strValues = strValues & Chr(9)
End If
strValues = strValues & vbNewLine
Next
'send to client end
Response.Write(strValues)
Response.End()