<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
    CodeBehind="Index.aspx.cs" Inherits="MvcApplication1.Views.Home.Index" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI.Mvc" Assembly="MvcApplication1" %>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <%= Html.Encode(ViewData["Message"]) %></h2>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
            http://asp.net/mvc</a>.
    </p>
    <% using (Html.Form("Home", "RadGridCommand", FormMethod.Post))
       { %>
    <telerik:MyGrid ID="MyGrid1" Skin="Hay" DataSourceID="LinqDataSource1" AllowPaging="true"
        AllowSorting="true" runat="server" AutoGenerateColumns="false" AllowAutomaticUpdates="true"
        AllowAutomaticDeletes="true" OnItemCommand="MyGrid1_ItemCommand">
        <MasterTableView DataKeyNames="EmployeeID" EditMode="InPlace" CommandItemDisplay="Top">
            <CommandItemTemplate>
                <div style="padding: 10px;">
                    <%# Html.ActionLink("Add new record", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "InitInsert", CommandArgument = "" }) %>
                </div>
            </CommandItemTemplate>
            <Columns>
                <telerik:GridTemplateColumn HeaderStyle-Width="30px">
                    <itemtemplate>
                        <%# Container.IsInEditMode ? Html.SubmitButton(Container.OwnerTableView.IsItemInserted ? "Insert" : "Update", Container.OwnerTableView.IsItemInserted ? "Insert" : "Update", new { style = "border:0;background:transparent none;text-decoration:underline; cursor: pointer;" }) : ""%>
                        <span style="margin-left: 6px;"><%# Container.IsInEditMode ? Html.ActionLink("Cancel", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Cancel", CommandArgument = Container.ItemIndexHierarchical }) : ""%></span>
                        <%# !Container.IsInEditMode ? Html.ActionLink("Edit", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Edit", CommandArgument = Container.ItemIndexHierarchical }) : ""%>
                    </itemtemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-Width="30px">
                    <itemtemplate>
                        <%# Html.ActionLink("Delete", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Delete", CommandArgument = Container.ItemIndexHierarchical })%>
                    </itemtemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-Width="30px">
                    <itemtemplate>
                        <%# Html.ActionLink("Select", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Select", CommandArgument = Container.ItemIndexHierarchical })%>
                    </itemtemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn>
                    <headertemplate>
                        <%# Html.ActionLink("EmployeeID", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Sort", CommandArgument = "EmployeeID" })%>
                    </headertemplate>
                    <itemtemplate>
                        <%# Eval("EmployeeID")%>
                    </itemtemplate>
                    <edititemtemplate>
                        <%# Container.OwnerTableView.IsItemInserted ? Html.TextBox("LargeEmployee.EmployeeID", Eval("EmployeeID").ToString()) : Eval("EmployeeID")%>
                    </edititemtemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn>
                    <headertemplate>
                        <%# Html.ActionLink("FirstName", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Sort", CommandArgument = "FirstName" })%>
                    </headertemplate>
                    <itemtemplate>
                        <%# Eval("FirstName")%>
                    </itemtemplate>
                    <edititemtemplate>
                        <%# Html.TextBox("LargeEmployee.FirstName", Eval("FirstName").ToString())%>
                    </edititemtemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn>
                    <headertemplate>
                        <%# Html.ActionLink("LastName", "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Sort", CommandArgument = "LastName" })%>
                    </headertemplate>
                    <itemtemplate>
                        <%# Eval("LastName")%>
                    </itemtemplate>
                    <edititemtemplate>
                        <%# Html.TextBox("LargeEmployee.LastName", Eval("LastName").ToString())%>
                    </edititemtemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <PagerTemplate>
                <% for (int i = 0; i < Math.Min(MyGrid1.PagerStyle.PageButtonCount, MyGrid1.PageCount); i++)
                   {%>
                <% if (i != MyGrid1.CurrentPageIndex)
                   {%>
                <%= Html.ActionLink((i + 1).ToString(), "RadGridCommand", new { ControlID = MyGrid1.ID, CommandName = "Page", CommandArgument = (i + 1) })%>
                <% }
                   else
                   { %>
                <%= (i + 1).ToString()%>
                <% } %>
                &nbsp;
                <% }%>
            </PagerTemplate>
        </MasterTableView>
    </telerik:MyGrid>
    <% } %>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="MvcApplication1.DataClasses1DataContext"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="LargeEmployees">
    </asp:LinqDataSource>
</asp:Content>
