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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
            function getItemsCount() {
                var grid = $find("<%= RadGrid1.ClientID %>");
                var masterTableView = grid.get_masterTableView();

                var selectedItems = masterTableView.get_selectedItems();

                alert("Number of selected items: " + selectedItems.length);

            }
        </script>
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1"></telerik:RadScriptManager>

        <telerik:RadComboBox runat="server" ID="RadCombobox1" OnSelectedIndexChanged="RadCombobox1_SelectedIndexChanged" AutoPostBack="true">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="Item 1" />
                <telerik:RadComboBoxItem runat="server" Text="Item 2" />
                <telerik:RadComboBoxItem runat="server" Text="Item 3" />
            </Items>
        </telerik:RadComboBox>

        <asp:Button Text="Get selected items count" runat="server" OnClientClick="getItemsCount();" />

        <telerik:RadGrid ID="RadGrid1" runat="server"
            OnNeedDataSource="RadGrid1_NeedDataSource"
            ClientSettings-Selecting-AllowRowSelect="true"
            AllowMultiRowSelection="true"
            AutoGenerateColumns="false">

            <PagerStyle AlwaysVisible="True" Position="Bottom" />

            <MasterTableView DataKeyNames="OrderID" CommandItemDisplay="Top" AllowCustomPaging="True" AllowPaging="True"
                TableLayout="Fixed" ClientDataKeyNames="OrderID, ProductID" PagerStyle-PageSizes="25;50;75;100">

                <CommandItemSettings ShowAddNewRecordButton="False"></CommandItemSettings>
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                </RowIndicatorColumn>

                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                </ExpandCollapseColumn>

                <Columns>
                    <telerik:GridClientSelectColumn HeaderStyle-Width="3em" UniqueName="ClientSelectColumn"></telerik:GridClientSelectColumn>

                    <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" SortExpression="OrderID"
                        UniqueName="OrderID" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ProductID" HeaderText="ProductID" SortExpression="ProductID"
                        UniqueName="ProductID" Visible="false">
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice"
                        UniqueName="UnitPrice">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity"
                        UniqueName="Quantity">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Discount" HeaderText="Discount" SortExpression="Discount"
                        UniqueName="Discount">
                    </telerik:GridBoundColumn>

                </Columns>

            </MasterTableView>
        </telerik:RadGrid>
    </form>
</body>
</html>
