Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
We tried to export the data to excel using radgrid option, it's working fine on single export. but we tried to export in for each loop, last file data's only exported. Is possible to export in loop? .


protected void btnexport_Click(object sender, EventArgs e)
{

string selectedimportfilesid = "";
IList<radlistboxitem> collection = ListBoxFileNames.CheckedItems;
string selectedfilename = "";
DataTable dtselect = new DataTable();
foreach (RadListBoxItem item in collection)
{
Label filename = (Label)item.FindControl("lblfilename");
Label Importfileid = (Label)item.FindControl("lblimportfileid");
selectedfilename = filename.Text;
selectedimportfilesid = Importfileid.Text;
dtselect = selectedexportfilelist(selectedimportfilesid);
testgrid.DataSource = dtselect;
testgrid.DataBind();
testgrid.ExportSettings.IgnorePaging = true;
testgrid.ExportSettings.FileName = selectedfilename
testgrid.ExportSettings.OpenInNewWindow = true;
testgrid.ExportSettings.Excel.FileExtension = "xls";
testgrid.MasterTableView.ExportToExcel();
}
}

Thanks in advance!!
Anil
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900