Hello,
I use ExportToExcel feature of RadGrid. I use business objects as data source, and if no data is available, export fails. This occurs only if paging is enabled in the ObjectDataSource. Please check my code. Should I create a support ticket?
Best regards, Oleg.
Windows XP SP2
RadGrid For ASP.NET AJAX 2008.1.619.35
Visual Studio 2008
.NET 3.5
Default.aspx.cs
Class1.cs
public class Class1
{
public Transaction[] GetData(int offset, int count)
{
return new Transaction[0];
}
public int SelectCount()
{
return 0;
}
}
public class Transaction
{
public string Name { get; set; }
public int Amount { get; set; }
}
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1"
GridLines="None">
<ExportSettings ExportOnlyData="True" IgnorePaging="True">
</ExportSettings>
<MasterTableView AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Amount" DataType="System.Int32" HeaderText="Amount"
SortExpression="Amount" UniqueName="Amount">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
EnablePaging="true" SelectCountMethod="SelectCount" StartRowIndexParameterName="offset"
MaximumRowsParameterName="count" TypeName="Class1"></asp:ObjectDataSource>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</form>
</body>
</html>
I use ExportToExcel feature of RadGrid. I use business objects as data source, and if no data is available, export fails. This occurs only if paging is enabled in the ObjectDataSource. Please check my code. Should I create a support ticket?
Best regards, Oleg.
Windows XP SP2
RadGrid For ASP.NET AJAX 2008.1.619.35
Visual Studio 2008
.NET 3.5
Default.aspx.cs
using System;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
RadGrid1.MasterTableView.ExportToExcel();
}
}
Class1.cs
public class Class1
{
public Transaction[] GetData(int offset, int count)
{
return new Transaction[0];
}
public int SelectCount()
{
return 0;
}
}
public class Transaction
{
public string Name { get; set; }
public int Amount { get; set; }
}
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1"
GridLines="None">
<ExportSettings ExportOnlyData="True" IgnorePaging="True">
</ExportSettings>
<MasterTableView AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Amount" DataType="System.Int32" HeaderText="Amount"
SortExpression="Amount" UniqueName="Amount">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
EnablePaging="true" SelectCountMethod="SelectCount" StartRowIndexParameterName="offset"
MaximumRowsParameterName="count" TypeName="Class1"></asp:ObjectDataSource>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</form>
</body>
</html>