I'm trying to use the ExportToCSV function and I can see it works ok with one of my grids, one that was created with the Designer. but when trying to generate a GridView on the fly it'll export a blank CSV, even when the grid's DataSource is filled with records.
01.
private
void
radButton1_Click(
object
sender, EventArgs e)
02.
{
03.
RadGridView tempGrid =
new
RadGridView();
04.
05.
GridViewTextBoxColumn firstName =
new
GridViewTextBoxColumn();
06.
firstName.FieldName =
"fname"
;
07.
tempGrid.Columns.Add(firstName);
08.
09.
GridViewTextBoxColumn lastName =
new
GridViewTextBoxColumn();
10.
lastName.FieldName =
"lname"
;
11.
tempGrid.Columns.Add(lastName);
12.
13.
GridViewTextBoxColumn emailAddress =
new
GridViewTextBoxColumn();
14.
emailAddress.FieldName =
"email"
;
15.
tempGrid.Columns.Add(emailAddress);
16.
17.
ContactsEntities csvList =
new
ContactsEntities();
18.
tempGrid.DataSource = (from c
in
csvList.CSVList select c).ToList();
19.
20.
ExportToCSV exporter =
new
ExportToCSV(tempGrid);
21.
string
fileName =
"D:\\ExportedData2.csv"
;
22.
exporter.RunExport(fileName);
23.
}