//prepare the output stream
Response.Clear();
Response.ContentType = "text/csv";
Response.AppendHeader("Content-Disposition",string.Format("attachment; filename={0}", fileName));
//write the csv column headers
DataTable dt1;
dt1 = ds.Tables[1];
foreach (DataRow row in dt1.Rows)
{
for (int i = 0; i < dt1.Columns.Count; i++)
{
Response.Write("\"" + row[i].ToString() + "\"");
Response.Write((i < dt1.Columns.Count - 1) ? delimiter : Environment.NewLine);
}
}
DataTable dt;
dt = ds.Tables[0];
//write the data
foreach (DataRow row in dt.Rows)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
Response.Write("\"" + row[i].ToString() + "\"" );
Response.Write((i < dt.Columns.Count - 1) ? delimiter : Environment.NewLine);
}
}
Response.End();
Subscribe to:
Post Comments (Atom)
Hash Table in C#
The Hashtable is a non-generic collection and used to store the key/value pairs based on the hash code of the key. Key will be used to acce...
-
Html.TextBoxFor in MVC 2 doesn't allow the setting of the value property using the object html attributes. syntax - <%= Html.Text...
-
Dictionary<string, string> DicSearch; DicSearch = new Dictionary<string, string>(); DicSearch.Add("1", "Mohi...
-
e.preventDefault() is the key method, to disable the default operations to proceed further. We first stop the event from further bubbli...
-
****************** Type 1 ********************* System.Nullable<DateTime> dt; dt = null; ****************** Type 2 **************...
No comments:
Post a Comment