Hi guys,
I have a following Radgrid:
<telerik:RadGrid ID="PrnPSRejectedGrid" runat="server" GridLines="None" OnExcelMLExportRowCreated="PrnPSRejectedGrid_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="PrnPSRejectedGrid_ExcelMLExportStylesCreated" OnItemCreated="PrnPSRejectedGrid_ItemCreated" OnNeedDataSource="PrnPSRejectedGrid_NeedDataSource" OnPdfExporting="PrnPSRejectedGrid_PdfExporting" OnSortCommand="PrnPSRejectedGrid_SortCommand">
<ExportSettings FileName="PrnPSRejectReport" OpenInNewWindow="true" IgnorePaging="true" ExportOnlyData="true">
<Excel Format="ExcelML" FileExtension="xls"/>
<Pdf FontType="Subset" PaperSize="letter" />
</ExportSettings>
<MasterTableView AutoGenerateColumns="false" >
<RowIndicatorColumn>
<HeaderStyle Width="10px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="10px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn HeaderText="TrkNo" DataField="TRKNO" UniqueName="TRKNO" ReadOnly="True" SortExpression="TRKNO" HeaderButtonType="TextButton">
<HeaderStyle Width="1px" />
<ItemStyle Width="1px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Rejected Reason Description" DataField="RRSNDESC" UniqueName="RRSNDESC" ReadOnly="True" SortExpression="RRSNDESC" HeaderButtonType="TextButton" >
<HeaderStyle Width="200px" />
<ItemStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="CLASS" SortExpression="SEP_CW_CRSE_CLASS" UniqueName="SEP_CW_CRSE_CLASS"> <ItemTemplate> <asp:Label ID="lbCRSEClass" runat="server" Visible="false" Text='<%# Eval("SEP_CW_CRSE_CLASS") %>' /> <asp:DropDownList ID="rdbCRSEClass" runat="server" Width="75px" OnSelectedIndexChanged="rdbCRSEClass_SelectedIndexChanged" AutoPostBack="true" CommandArgument='<%# ((GridItem)Container).ItemIndex %>' /> <%--<telerik:RadComboBox ID="rdbCRSEClass" runat="server" OnSelectedIndexChanged="rdbCRSEClass_SelectedIndexChanged" AutoPostBack="true" CommandArgument='<%# DataBinder.Eval(Container,"ItemIndex") %>'> </telerik:RadComboBox>--%> <%--<telerik:RadComboBox ID="rdbCRSEClass" runat="server" OnSelectedIndexChanged="rdbCRSEClass_SelectedIndexChanged" AutoPostBack="true" CommandArgument='<%# ((GridItem)Container).ItemIndex %>'> </telerik:RadComboBox>--%> </ItemTemplate> </telerik:GridTemplateColumn>//RadComboBoxSelectedIndexChangedEventArgs protected void rdbCRSEClass_SelectedIndexChanged(object sender, EventArgs e) { string cmdArg = ((DropDownList)sender).Attributes["CommandArgument"]; //string cmdArg = ((RadComboBox)sender).Attributes["CommandArgument"]; int ItemIndex = Convert.ToInt32(cmdArg); DropDownList rdbGEGRAD = (DropDownList)(gvClassTERM.Items[ItemIndex].FindControl("rdbGEGRAD")); DropDownList rdbCRSEClass = (DropDownList)(gvClassTERM.Items[ItemIndex].FindControl("ddltCRSEClass"));}My problem is my radgrid only exports when the user selects page 1 on the rad grid. ie. If user selects page 2 through infinity and then exports it the grid. The excel spreadsheet will have the column names but no data. But if the user is has paging page 1 selected it will export the entire data set. I stumped.
I have attaced the code that I am using. Thank you for any help
<
telerik:RadButton ID="RadBtnExport" CssClass="button" Width="150px" Text="Export to Excel" OnClick="RadBtnExport_Click" runat="server" Skin="WebBlue"></telerik:RadButton>
<
telerik:RadGrid ID="RadGridResults" runat="server"
AllowPaging="True" AllowSorting="True"
AllowFilteringByColumn="True" GridLines="None"
EnableLinqExpressions="False" PageSize="30" Width="900px" Skin="WebBlue"
EnableImageSprites="True" AllowCustomPaging="true" ExportSettings-ExportOnlyData="true"
AutoGenerateColumns="true" ExportSettings-IgnorePaging="true"
OnNeedDataSource="RadGridSearchResults_NeedDataSource" OnSortCommand="RadComboBoxReport_SortCommand">
<MasterTableView CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false" CommandItemSettings-ShowExportToExcelButton="true">
<RowIndicatorColumn>
<HeaderStyle Width="10px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="10px"></HeaderStyle>
</ExpandCollapseColumn>
<PagerStyle Mode="NumericPages" AlwaysVisible="true"/>
<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" />
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="True" SaveScrollPosition="True">
</Scrolling>
</ClientSettings>
</telerik:RadGrid>
protected void RadBtnExport_Click(object sender, System.EventArgs e)
{
try
{
if (RadGridResults.Items.Count > 0)
{
RadGridResults.ExportSettings.ExportOnlyData =
true;
RadGridResults.ExportSettings.IgnorePaging =
true;
//call the method on export formatting
RadGridResults.ExcelExportCellFormatting +=
new Telerik.Web.UI.OnExcelExportCellFormattingEventHandler(RadGridResults_ExcelExportCellFormatting);
RadGridResults.MasterTableView.ExportToExcel();
}
}
catch (Exception ex)
{
StackTrace stackTrace = new StackTrace();
LogException.LogErrorMessage(ex, stackTrace.GetFrame(1).GetMethod().Name);
lblErrMsg.Text =
Messages.ReportExportError;
}
}
protected void RadGridResults_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)
{
e.Cell.Style[
"mso-number-format"] = @"0000";
}