This question is locked. New answers and comments are not allowed.
Hello,
I am trying to export the contents of my RadGridView (including all pages) to Excel. For some reason, it is only exporting the current page. I tried to set the RadDataPager PageSize property to 0 but that doesnt work. I figure it may be something that I am missing that has to be done that is specific to having RadDataServiceDataSource as my source of data.
See code below:
Thanks,
Jorge
I am trying to export the contents of my RadGridView (including all pages) to Excel. For some reason, it is only exporting the current page. I tried to set the RadDataPager PageSize property to 0 but that doesnt work. I figure it may be something that I am missing that has to be done that is specific to having RadDataServiceDataSource as my source of data.
See code below:
private void exportButton_Click(object sender, RoutedEventArgs e)
{
string extension = "xls";
string selectedItem = "Excel";
ExportFormat format = ExportFormat.Html;
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, selectedItem);
dialog.FilterIndex = 1;
int originalPageSize = radDataPager1.PageSize;
int originalPageIndex = radDataPager1.PageIndex;
if (dialog.ShowDialog() == true)
{
using (Stream stream = dialog.OpenFile())
{
radDataPager1.PageSize = 0;
GridViewExportOptions options = new GridViewExportOptions();
options.Format = format;
options.ShowColumnHeaders = true;
options.Encoding = System.Text.Encoding.UTF8;
RadGridView1.Export(stream, options);
}
radDataPager1.PageSize = originalPageSize;
radDataPager1.PageIndex = originalPageIndex;
}
Thanks,
Jorge