I am encountering a null reference exception when I set ExportOnlyData="true" and try to export to any format. If I set ExportOnlyData="false", everything works fine.
Here are the exception details:
I am using advanced databinding for my datasource, but I have noticed that the NeedsDataSource event never fires when I try to export only data:
Any ideas?
Here are the exception details:
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.RadAjaxControl.OnPagePreRenderComplete(Object sender, EventArgs e) +116 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +11039453 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3671Here is my markup:
<telerik:RadGrid ID="grdResults" Visible="true" runat="server" Skin="WebBlue" AutoGenerateColumns="false" |
PageSize="20" AllowPaging="true" AllowSorting="true" OnItemCommand="grdResults_ItemCommand" |
OnNeedDataSource="grdResults_NeedDataSource"> |
<ExportSettings FileName="EmployeeSearchResults" ExportOnlyData="true"> |
</ExportSettings> |
<PagerStyle Mode="NumericPages" HorizontalAlign="Center" VerticalAlign="Top" AlwaysVisible="true" |
Position="Bottom"></PagerStyle> |
<MasterTableView DataKeyNames="UserId" CommandItemDisplay="Top"> |
<CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true" /> |
<Columns> |
<telerik:GridTemplateColumn> |
<ItemTemplate> |
<telerik:RadAjaxPanel runat="server"> |
<asp:CheckBox ID="chk" runat="server" Checked='<%# Eval("Selected") %>' AutoPostBack="true" OnCheckedChanged="chk_CheckedChanged" /> |
<asp:HiddenField ID="hdn" runat="server" Value=<%# Eval("UserId") %> /> |
</telerik:RadAjaxPanel> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn SortExpression="EmployeeId" DataField="EmployeeId" HeaderText="Employee ID"> |
</telerik:GridBoundColumn> |
<telerik:GridButtonColumn ButtonType="LinkButton" DataTextField="UserName" HeaderText="Name" |
SortExpression="UserName" CommandName="UserProfile"> |
</telerik:GridButtonColumn> |
<telerik:GridBoundColumn SortExpression="Title" DataField="Title" HeaderText="Title"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="CompanyName" DataField="CompanyName" HeaderText="Org / Org Unit"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="ManagerName" DataField="ManagerName" HeaderText="Manager"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="EmailAddress" DataField="EmailAddress" HeaderText="Email Address"> |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
I am using advanced databinding for my datasource, but I have noticed that the NeedsDataSource event never fires when I try to export only data:
protected void grdResults_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
EmployeeSearchCriteriaDTO criteria = SessionManager.SM.EmployeeSearchCriteria; |
if (criteria != null) |
{ |
IList<EmployeeSearchResultDTO> temp = EmployeeSearchManager.Query2(criteria); |
if (SessionManager.SM.ComparisonUserIDs != null) |
{ |
foreach (int id in SessionManager.SM.ComparisonUserIDs) |
{ |
EmployeeSearchResultDTO user = temp.FirstOrDefault(r => r.UserId == id); |
if (user != null) |
user.Selected = true; |
} |
} |
grdResults.DataSource = temp; |
} |
} |
Any ideas?