Click here to Skip to main content
12,757,627 members (36,536 online)
Rate this:
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 1: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)

Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100