I have a datatable called datasource that I use to populate a gridview and to use to export the data to a csv file, however for some reason it is leaving the last cell of the last record in the csv blank. Just wondering if anyone has came across this before or knows of any ways to fix this.

Thanks :)

Recommended Answers

All 4 Replies

it is leaving the last cell of the last record in the csv blank

So the data could be seen in the gridview but when you run the export process, it is missing that last piece of information in the csv file?

Yea thats what is happening. The csv is being generated by passing the datatable used to populate the gridview to a memory stream and then exported to csv.

Sounds like you arent reading in all of the data or the stream is terminating before you export to csv. could there be someting in the cell to the left that is being read as a delimeter whereby your process thinks its at the end of the row?

No I don't think so. It's only causing this error on a few of the csvs. The majority of them are displaying all of the cells. It's very strange.

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.