<%@ 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">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>

            <telerik:RadGrid ID="HomeRadGrid" runat="server" DataSourceID="SqlDataSource1"
                AllowSorting="True"
                AllowFilteringByColumn="True" CellSpacing="0" Culture="it-IT" GridLines="None" OnItemCommand="HomeRadGrid_ItemCommand"
                ShowGroupPanel="True">

                <PagerStyle Mode="NextPrevAndNumeric" />

                <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="CustomerID">

                    <ColumnGroups>
                        <telerik:GridColumnGroup Name="CustomerID" HeaderText="CustomerID"
                            HeaderStyle-HorizontalAlign="Center" />

                        <telerik:GridColumnGroup Name="CompanyName" HeaderText="CompanyName"
                            HeaderStyle-HorizontalAlign="Center" />
                    </ColumnGroups>
                    <CommandItemSettings RefreshText="" ShowAddNewRecordButton="false" />
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldAlias="CustomerID" FieldName="CustomerID"></telerik:GridGroupByField>
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="ContactName" SortOrder="Descending"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldAlias="Address" FieldName="Address"></telerik:GridGroupByField>
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="CustomerID"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>

                    <Columns>

                        <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton"
                            DataField="ContactName" UniqueName="ContactName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton"
                            DataField="CompanyName" UniqueName="CompanyName">
                        </telerik:GridBoundColumn>

                    </Columns>

                    <NestedViewTemplate>
                    </NestedViewTemplate>

                </MasterTableView>

                <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                </ClientSettings>

                <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>

            </telerik:RadGrid>



            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = @CustomerID"
                InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [Address]) VALUES (@CustomerID, @CompanyName, @ContactName, @Address)"
                SelectCommand="SELECT * FROM [Customers]"
                UpdateCommand="UPDATE [Customers] SET [CompanyName] = @CompanyName, [ContactName] = @ContactName, [Address] = @Address WHERE [CustomerID] = @CustomerID">
                <DeleteParameters>
                    <asp:Parameter Name="CustomerID" Type="String"></asp:Parameter>
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CustomerID" Type="String"></asp:Parameter>
                    <asp:Parameter Name="CompanyName" Type="String"></asp:Parameter>
                    <asp:Parameter Name="ContactName" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Address" Type="String"></asp:Parameter>
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CompanyName" Type="String"></asp:Parameter>
                    <asp:Parameter Name="ContactName" Type="String"></asp:Parameter>
                    <asp:Parameter Name="Address" Type="String"></asp:Parameter>
                    <asp:Parameter Name="CustomerID" Type="String"></asp:Parameter>
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
    </form>
</body>
</html>
