<%@ Page Language="C#" %>

<%@ 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>

    <script runat="server">
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            ((RadGrid) source).DataSource = new[]
                                                {
                                                    new {Text = "1"}, new {Text = "2"}, new {Text = "3"}, new {Text = "4"},
                                                    new {Text = "5"}
                                                };
        }

        protected void CsvButton_Click(object sender, EventArgs e)
        {
            RadGrid1.MasterTableView.ExportToCSV();
        }
        protected void ExcelButton_Click(object sender, EventArgs e)
        {
            RadGrid1.MasterTableView.ExportToExcel();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager runat="server" ID="ScriptManager1" />
        <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false">
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="This is a hyperlink column">
                        <ItemTemplate>
                            <asp:HyperLink runat="server" ID="hyperLink1" NavigateUrl="~/Default.aspx" Text='<%#Eval("Text") %>'></asp:HyperLink>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:Button runat="server" ID="CsvButton" OnClick="CsvButton_Click" Text="ExportToCSV" />
        <asp:Button runat="server" ID="ExcelButton" OnClick="ExcelButton_Click" Text="ExportToExcel" />
    </div>
    </form>
</body>
</html>
