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

<!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>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadMenu1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="AjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="AjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadMenu2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadMenu2" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="AjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadMenu2" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="AjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="AjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="75px"
            Transparency="25" Width="75px" Skin="WebBlue">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function RowClick(sender, eventArgs) {
                    var menu;
                    menu = $find("<%= RadMenu1.ClientID %>");
                    var item = sender.get_masterTableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                    document.getElementById("radGridClickedRowValue").value = item.getDataKeyValue("CustomerID");
                    menu.show(eventArgs.get_domEvent());
                }
            </script>
        </telerik:RadCodeBlock>
        <p>
            Right-click the grid to open context menu.</p>
        <telerik:RadGrid ID="RadGrid2" runat="server" Width="95%" AutoGenerateColumns="False"
            PageSize="10" AllowSorting="True" AllowPaging="True" Skin="WebBlue" DataSourceID="AccessDataSource1">
            <PagerStyle Mode="NumericPages" />
            <MasterTableView DataKeyNames="CustomerID" ClientDataKeyNames="CustomerID" Width="100%" Name="Customers" DataSourceID="AccessDataSource1">
                <Columns>
                    <telerik:GridBoundColumn HeaderText="CustomerID" DataField="CustomerID" HeaderButtonType="TextButton"
                        UniqueName="CustomerID" SortExpression="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Contact Name" DataField="ContactName" HeaderButtonType="TextButton"
                        UniqueName="ContactName" SortExpression="ContactName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Company" DataField="CompanyName" HeaderButtonType="TextButton"
                        UniqueName="CompanyName" SortExpression="CompanyName">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowClick="RowClick" />
            </ClientSettings>
        </telerik:RadGrid>
        <asp:AccessDataSource ID="AccessDataSource1" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT * FROM Customers"
            runat="server"></asp:AccessDataSource>
        <br />
        <input type="hidden" id="radGridClickedRowValue" name="radGridClickedRowValue" />
        <br />
        <telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="WebBlue" OnItemClick="RadMenu_ItemClick">
            <Items>
                <telerik:RadMenuItem Text="Edit" />
            </Items>
        </telerik:RadContextMenu>
        <br />
        <br />
    </div>
    </form>
</body>
</html>
