<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeFile="List.aspx.cs" Inherits="List" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>
<%@ Register src="~/DynamicData/Content/FilterUserControl.ascx" tagname="DynamicFilter" tagprefix="asp" %>
<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.Web.UI.WebControls" tagprefix="asp" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="dynamic" Namespace="Telerik.Web.UI.DynamicData" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <h2><%= table.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="RadGrid1" 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="RadGrid1" AllowPaging="True" AllowSorting="True" 
			    AutoGenerateColumns="false" runat="server" DataSourceID="GridDataSource" 
			    SelectedItemStyle-BackColor="LightBlue" AllowFilteringByColumn="true">
			       <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:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true">                
            </asp:EntityDataSource>

            <br />

            <div class="bottomhyperlink">
                <asp:HyperLink ID="InsertHyperLink" runat="server">
                <img runat="server" src="~/DynamicData/Content/Images/plus.gif" 
                    alt="Insert new item" />Insert new item</asp:HyperLink>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
