Author: bazmanblue | Posted on: 7/15/2010 9:12:39 AM | Views : 452

  
Hopefully this seems quite easy to all of you as i am quite new to asp and c#

I am trying to export data to a csv file in my web application.

I have the following class to enable this but i want to know how to call the class on Page_Load?

public class CSVExporter
{
public static void WriteToCSV(List<Category> categoryList)
{
string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AddHeader("Pragma", "public");
WriteColumnName();
foreach (Category person in categoryList)
{
WriteUserInfo(person);
Go to the complete details ...