Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Dear friends,
I am using VS 2005 ,,
I have a web application.
How to export the data in the dataset to notepad in client system?
Thanks in advance
Posted 26-Nov-12 0:16am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think you can dump your data to the web page all nicely formatted off course in columns (which you may have to in your script) - for review and then save the data that is displayed (meaning the webpage) using the document.exec command and the IDM_SaveAs (?)
I cannot remember its been so long since i used it,
but you can find more info Here
Last i used it was in IE6 but the calling syntax was slightly different and i only came across it when i was looking for how to add an add to favorites button and noticed it was very similar.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

protected void btn_Download_Click(object sender, EventArgs e)
DataSet ds = new DataSet();
ds = GetDatatable();
string filename = "MyObCustomerCard.txt";
// Exporting Data to text file
ExportDataTabletoFile(ds.Tables[0], " ", true, Server.MapPath("~/image/MyObCustomerCard.txt"));
#region download notepad or text file.
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
string aaa = Server.MapPath("~/contents/" + filename);
Response.TransmitFile(Server.MapPath("~/image/" + filename));
public void ExportDataTabletoFile(DataTable datatable, string delimited, bool exportcolumnsheader, string file)
        StreamWriter str = new StreamWriter(file, false, System.Text.Encoding.Default);
        if (exportcolumnsheader)
            string Columns = string.Empty;
            foreach (DataColumn column in datatable.Columns)
                Columns += column.ColumnName + delimited;
            str.WriteLine(Columns.Remove(Columns.Length - 1, 1));
        foreach (DataRow datarow in datatable.Rows)
            string row = string.Empty;
            foreach (object items in datarow.ItemArray)
                row += items.ToString() + delimited;
            str.WriteLine(row.Remove(row.Length - 1, 1));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Guruprasad.K.Basavaraju 390
1 Shai Vashdi 349
2 Sergey Alexandrovich Kryukov 325
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 8,979
1 OriginalGriff 5,280
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263

Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid