<%@ Page Language="VB" MasterPageFile="~/Site.master" CodeBehind="ListDetails.aspx.vb"
    Inherits="WebApplication2.ListDetails" %>

<%@ Register Src="~/DynamicData/Content/GridViewPager.ascx" TagName="GridViewPager"
    TagPrefix="asp" %>
<%@ Register Src="~/DynamicData/Content/FilterUserControl.ascx" TagName="DynamicFilter"
    TagPrefix="asp" %>
<%@ Register Namespace="WebApplication2.Telerik.Web.UI.DynamicData" TagPrefix="dynamic"
    Assembly="WebApplication2" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />
    <%-- <h2>
        <%= GridDataSource.GetTable().DisplayName %></h2>--%>
    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="List of validation errors" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1"
                Display="None" />
            <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1"
                Display="None" />
            <asp:FilterRepeater ID="FilterRepeater" runat="server">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
                    <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
                </ItemTemplate>
                <FooterTemplate>
                    <br />
                    <br />
                </FooterTemplate>
            </asp:FilterRepeater>
            <dynamic:DynamicRadGrid ID="GridView1" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="false"
                runat="server" DataSourceID="GridDataSource" SelectedItemStyle-BackColor="LightBlue">
                <MasterTableView>
                    <Columns>
                        <telerik:grideditcommandcolumn />
                        <telerik:gridbuttoncolumn commandname="Delete" text="Delete" confirmtext="Are you sure?" />
                        <telerik:gridbuttoncolumn commandname="Select" text="Select" />
                    </Columns>
                </MasterTableView>
            </dynamic:DynamicRadGrid>
            <%--<asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"
                AutoGenerateSelectButton="True" AutoGenerateEditButton="True" AutoGenerateDeleteButton="true"
                AllowPaging="True" AllowSorting="True" OnDataBound="OnGridViewDataBound"
                OnRowEditing="OnGridViewRowEditing" OnSelectedIndexChanging="OnGridViewSelectedIndexChanging"
                OnRowDeleted="OnGridViewRowDeleted" OnRowUpdated="OnGridViewRowUpdated"
                OnRowCreated="OnGridViewRowCreated" CssClass="gridview">

                <PagerStyle CssClass="footer" />        
                <SelectedRowStyle CssClass="selected" />
                <PagerTemplate>
                    <asp:GridViewPager runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    There are currently no items in this table.
                </EmptyDataTemplate>
            </asp:GridView>--%>
            <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true">
                <WhereParameters>
                    <asp:DynamicControlParameter ControlId="FilterRepeater" />
                </WhereParameters>
            </asp:LinqDataSource>
            <asp:Panel ID="DetailsPanel" runat="server">
                <br />
                <br />
                <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="DetailsDataSource"
                    AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" AutoGenerateInsertButton="true"
                    OnModeChanging="OnDetailsViewModeChanging" OnPreRender="OnDetailsViewPreRender"
                    OnItemDeleted="OnDetailsViewItemDeleted" OnItemUpdated="OnDetailsViewItemUpdated"
                    OnItemInserted="OnDetailsViewItemInserted">
                </asp:DetailsView>
                <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableInsert="true"
                    EnableUpdate="true">
                    <WhereParameters>
                        <asp:DynamicControlParameter ControlId="GridView1" />
                    </WhereParameters>
                </asp:LinqDataSource>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
