<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ContentForMaster.aspx.cs" Inherits="Default12" Title="Untitled Page" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowSelected(sender, args)
            {
                document.getElementById("<%= Label1.ClientID %>").innerHTML =
                 "<b>CustomerID: </b>" + args.getDataKeyValue("CustomerID") +
                 "<br />" +
                 "<b>CompanyName: </b>" + args.getDataKeyValue("CompanyName");
            }
            
            function GetFirstDataItemKeyValues()
            {
             var firstDataItem = $find("<%= RadGrid1.MasterTableView.ClientID %>").get_dataItems()[0];
             var keyValues =
                    'CustomerID: "' + firstDataItem.getDataKeyValue("CustomerID") + '"' +
                 ' \r\n' +
                 'CompanyName: "' + firstDataItem.getDataKeyValue("CompanyName") + '"';
             alert(keyValues);
            }
        </script>
</telerik:RadCodeBlock>
        
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:Button ID="Button1" CssClass="button" Width="220px" Text="Get first GridDataItem key/values" OnClientClick="GetFirstDataItemKeyValues(); return false;" runat="server" />
        <br /><br />
        <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" GridLines="None" ShowStatusBar="true"
            AllowPaging="true" PageSize="10" Width="97%" AllowSorting="true" runat="server" Skin="Default">
            <MasterTableView Width="100%" ClientDataKeyNames="CustomerID,CompanyName" />
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
                <ClientEvents OnRowSelected="RowSelected" />
            </ClientSettings>
        </telerik:RadGrid>
        <br />
        <br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
         <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient"
            SelectCommand="SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers"
            runat="server"></asp:SqlDataSource>
</asp:Content>

