I have an editable radgrid and I want to export it to excel.
This is my aspx:
<telerik:RadAjaxPanel ID="rjxPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<asp:UpdatePanel ID="updtPanel" runat="server">
<ContentTemplate>
<telerik:RadButton ID="btnExport" runat="server" OnClick="btnExport_Click" Text="Export" />
<telerik:RadGrid ID="rgCostAllocation" runat="server" OnNeedDataSource="rgCostAllocation_NeedDataSource"
OnItemDataBound="rgCostAllocation_ItemDataBound" OnDeleteCommand="rgCostAllocation_DeleteCommand"
ShowFooter="true">
<ExportSettings Excel-Format="ExcelML" ExportOnlyData="true" IgnorePaging="true" HideStructureColumns="true"></ExportSettings>
<MasterTableView CommandItemDisplay="Top">
<CommandItemSettings ExportToExcelText="Export" ShowExportToExcelButton="true" />
<Columns>
<telerik:GridBoundColumn DataField="CostAllocationId" HeaderText="CostAllocationId"
UniqueName="CostAllocationId" Display="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="AllocationLevel" HeaderText="Level" UniqueName="AllocationLevel"
AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" Display="false">
<ItemTemplate>
<telerik:RadNumericTextBox ID="txtLevel" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.AllocationLevel") %>'
NumberFormat-AllowRounding="false" NumberFormat-DecimalDigits="0" />
</ItemTemplate>
<FooterTemplate>
<telerik:RadNumericTextBox ID="txtFLevel" runat="server" NumberFormat-AllowRounding="false"
NumberFormat-DecimalDigits="0" />
</FooterTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="SenderDescription" HeaderText="Sender" UniqueName="SenderCostCenterId" AllowFiltering="true"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
<ItemTemplate>
<telerik:RadComboBox ID="rcbSender" runat="server"
MarkFirstMatch="True" AutoPostBack="true"
Width="170px" OnItemsRequested ="rcbSender_ItemsRequested"
height="200px" EnableLoadOnDemand="True"
ItemRequestTimeout ="500" DropDownWidth="280px"
DataTextField="CostCentreDescription"
DataValueField="CostCentreID" ExpandEffect="pixelate">
<headertemplate>
<table width="92%">
<tr>
<td style="font-weight:bold; width:50%;"> Cost Centre Description</td>
<td style="font-weight:bold; width:50%;">Cost Centre Code</td>
</tr>
</table>
</headertemplate>
<itemtemplate>
<table width="100%">
<tr>
<td style="width: 50%; font-size: 8pt; font-family: Arial;" align="left">
<%# DataBinder.Eval(Container, "Attributes['DataValue']") %>
</td>
<td align="left" style="font-size: 8pt; width: 50%; font-family: Arial;">
<%# DataBinder.Eval(Container, "Attributes['DataText']")%>
</td>
</tr>
</table>
</itemtemplate>
</telerik:RadComboBox>
</ItemTemplate>
<FooterTemplate>
<telerik:RadComboBox ID="rcbFSender" runat="server"
MarkFirstMatch="True" AutoPostBack="true"
Width="170px" OnItemsRequested ="rcbFSender_ItemsRequested"
height="200px" EnableLoadOnDemand="True" ItemRequestTimeout ="500"
DataTextField="CostCentreDescription"
DataValueField="CostCentreID"
DropDownWidth="280px"
ExpandEffect="pixelate" >
<headertemplate>
<table width="92%">
<tr>
<td style="font-weight:bold; width:50%;"> Cost Centre Description</td>
<td style="font-weight:bold; width:50%;">Cost Centre Code</td>
</tr>
</table>
</headertemplate>
<itemtemplate>
<table width="100%">
<tr>
<td style="width: 50%; font-size: 8pt; font-family: Arial;" align="left">
<%# DataBinder.Eval(Container, "Attributes['DataValue']") %>
</td>
<td align="left" style="font-size: 8pt; width: 50%; font-family: Arial;">
<%# DataBinder.Eval(Container, "Attributes['DataText']")%>
</td>
</tr>
</tr>
</table>
</itemtemplate>
</telerik:RadComboBox>
</FooterTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="AllocationPercentage" HeaderText="Percentage"
UniqueName="AllocationPercentage" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
<ItemTemplate>
<telerik:RadNumericTextBox Width="60px" ID="txtPercentage" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.AllocationPercentage") %>'
Type="Percent" />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblSumPercentage" runat="server" />
<telerik:RadNumericTextBox Width="60px" ID="txtFPercentage" runat="server" Type="Percent" />
<telerik:RadButton ID="btnAddNew" runat="server" OnClick="btnAddNew_Click" Text="Add New" />
</FooterTemplate>
<ItemStyle Width="15%" />
</telerik:GridTemplateColumn>
<telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" UniqueName="DeleteCommandColumn"
HeaderText="Delete" ConfirmText="Are you sure you want to delete?" Text="Delete">
<ItemStyle HorizontalAlign="Center" Width="3%" />
<HeaderStyle HorizontalAlign="Center" Width="3%" />
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
</telerik:RadAjaxPanel>
This is my .cs
protected void btnExport_Click(object sender, EventArgs e)
{
try
{
rgCostAllocation.MasterTableView.ExportToExcel();
}
catch (Exception ex)
{
XITingExceptionProcessor.ProcessException(this, ex);
}
}
I have a master page with RadAjaxManager.
When I try to export to excel, it doesn't work because of RadAjaxPanel.
So when I try to export by commenting the RadAjaxPanel, it exports to excel but with no data, a totally blank sheet.
Could you please help me with this?
Thanks,
Lok..