<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function pageLoad(sender, eventArgs) {
                BindGrid(0);
            }
            function GridCommand(sender, eventArgs) {
                if (eventArgs.get_commandName() == "Page") {
                    eventArgs.set_cancel(true);
                    BindGrid(eventArgs.get_tableView().get_currentPageIndex());
                }
            }
            function BindGrid(pageIndex) {
                var data = new Array();
                for (var i = pageIndex * 4; i < (pageIndex + 1) * 4 && i < 5; i++) { //4 == pageSize, 5 == virtualItemCount
                    data.push({ "ID": i, "Name": "Name" + i.toString() });
                }                
                var grid = $find("<%= RadGrid1.ClientID %>");
                grid.get_masterTableView().set_virtualItemCount(5);
                grid.get_masterTableView().set_dataSource(data);
                grid.get_masterTableView().dataBind();
            }
        </script>
    </telerik:RadCodeBlock>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="4">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Name" DataField="Name" UniqueName="Name">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="96px" />
                <ClientEvents OnCommand="GridCommand" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
    </form>
</body>
</html>
