Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to export the data to excel using radgrid option, it's working fine on single export. but I tried to export in for each loop, last file data's only exported. Is possible to export in loop?
C#
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();
    }
}
Posted
Updated 24-May-15 22:33pm
v2

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