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

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!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>
    <style type="text/css">




    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager runat="server" ID="Manager1">
        </asp:ScriptManager>

        <script type="text/javascript">
    
           function GridCreated(sender, args)
           {
            if(sender.get_masterTableView().get_dataItems()[0].get_element().cells[0].className == "rgGroupCol")
            {
            alert("The grid control is grouped");
            }
            else
            {
            alert("The grid control is not grouped");     
            }      
           }
    
        </script>

        <telerik:RadGrid AllowMultiRowEdit="True" ID="RadGrid1" ShowStatusBar="True" DataSourceID="AccessDataSource1"
            runat="server" AutoGenerateColumns="False" PageSize="7" GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound"
            OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" AllowAutomaticInserts="True"
            OnItemInserted="RadGrid1_ItemInserted" ShowGroupPanel="True">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView
             DataSourceID="AccessDataSource1" DataKeyNames="CategoryID"             
                AllowMultiColumnSorting="True">
                
                <GroupByExpressions>
                <telerik:GridGroupByExpression>
                <GroupByFields>
                <telerik:GridGroupByField FieldName="CategoryID" />
                </GroupByFields>
                <SelectFields>
                <telerik:GridGroupByField FieldName="CategoryID" />
                </SelectFields>
                </telerik:GridGroupByExpression>
                </GroupByExpressions>
                
                <Columns>
                
                <telerik:GridEditCommandColumn>
                     </telerik:GridEditCommandColumn>
                
                    <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" HeaderText="CategoryID"
                        SortExpression="CategoryID" UniqueName="CategoryID">
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn UniqueName="CategoryName" DataSourceID="AccessDataSource1"
                        ListTextField="CategoryName" ListValueField="CategoryName">
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"
                        UniqueName="Description">
                    </telerik:GridBoundColumn>      
                </Columns>
                <EditFormSettings>
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                </EditFormSettings>           
              
            </MasterTableView>            
            <ClientSettings AllowDragToGroup="True">
            <ClientEvents OnGridCreated="GridCreated" />
            </ClientSettings>
        </telerik:RadGrid><asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb"
            DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = ?" InsertCommand="INSERT INTO [Categories] ([CategoryID], [CategoryName], [Description]) VALUES (?, ?, ?)"
            SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"
            UpdateCommand="UPDATE [Categories] SET [CategoryName] = ?, [Description] = ? WHERE [CategoryID] = ?">
            <DeleteParameters>
                <asp:Parameter Name="CategoryID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="CategoryName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="CategoryID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="CategoryID" Type="Int32" />
                <asp:Parameter Name="CategoryName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
            </InsertParameters>
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/Nwind.mdb"          
            SelectCommand="SELECT TOP 1 [Description] FROM [Categories]">           
        </asp:AccessDataSource>
    </form>
</body>
</html>
