This is a migrated thread and some comments may be shown as answers.

Radgrid Excel Export In Loop

2 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
keerthivasan
Top achievements
Rank 1
keerthivasan asked on 25 May 2015, 09:07 AM
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?
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();
}
}

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 May 2015, 07:07 AM
Hello,

I am not quite sure what is the functionality that you would like to implement. Would you elaborate in more detail why would you need to export RadGrid in a loop?

In case you would like to export multiple RadGrid controls you can use the Export Infrastructure. Check out the following article that describes the functionality in more detail.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
keerthivasan
Top achievements
Rank 1
answered on 02 Jun 2015, 04:53 AM
Thank you for your answer. I already completed the process with Export Infrastructure.It's working good. The multiple files exported and saved to specified path,then download the exported files in zip format.
Tags
Grid
Asked by
keerthivasan
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
keerthivasan
Top achievements
Rank 1
Share this question
or