<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="LinqSqlEpisodeVProVid._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <asp:DropDownList ID="DropDownFilter" runat="server" 
                    DataSourceID="CategoryDataSource" 
                    DataTextField="CategoryName" 
                    DataValueField="CategoryID" 
                    AutoPostBack="true">
                        </asp:DropDownList>
  
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="ProductID" DataSourceID="LinqDataSource1" GridLines="Horizontal" OnRowUpdated="GridView1_RowUpdated">
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
            <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
<%--            <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />--%>
            <asp:TemplateField HeaderText="Supplier" SortExpression="Supplier.CompnayName">
                <ItemTemplate>
                   <%#Eval("Supplier.CompanyName") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="SupplierDataSource" DataTextField="CompanyName" DataValueField="SupplierID" 
                            SelectedValue='<%# Bind("SupplierID") %>'>
                        </asp:DropDownList>
                 </EditItemTemplate>
            </asp:TemplateField>
<%--            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />--%>
             <asp:TemplateField HeaderText="Category" SortExpression="Category.CategoryName">
                  <ItemTemplate>
                    <%#Eval("Category.CategoryName") %>
                  </ItemTemplate>
                 <EditItemTemplate>
                     <asp:DropDownList ID="DropDownList2" runat="server" 
                            DataSourceID="CategoryDataSource" DataTextField="CategoryName" DataValueField="CategoryID" 
                            SelectedValue='<%# Bind("CategoryID") %>'>
                        </asp:DropDownList>
                 </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
<%--            <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />--%>
            <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
            <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
            <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
            <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
        </Columns>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <SortedAscendingCellStyle BackColor="#F4F4FD" />
        <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
        <SortedDescendingCellStyle BackColor="#D8D8F0" />
        <SortedDescendingHeaderStyle BackColor="#3E3277" />
    </asp:GridView>
    <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
    <asp:LinqDataSource ID="SupplierDataSource" runat="server" ContextTypeName="LinqSqlEpisodeVProVid.NorthwindDataContext" EntityTypeName="" TableName="Suppliers">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="CategoryDataSource" runat="server" ContextTypeName="LinqSqlEpisodeVProVid.NorthwindDataContext" EntityTypeName="" TableName="Categories">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="LinqSqlEpisodeVProVid.NorthwindDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName="" TableName="Products" Where="CategoryID == @CategoryID">
        <WhereParameters>
            <asp:ControlParameter ControlID="DropDownFilter" Name="CategoryID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>

  
</asp:Content>
