<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true" CodeFile="AlbumManager.aspx.cs" Inherits="Admin_AlbumManager" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <center>
    <asp:Label ID="Label2" runat="server" Text="<h3>Manage Albums</h3>"></asp:Label>
    </center>
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False" DataKeyNames="AlbumID" DataSourceID="SqlDataSource1"
        Height="50px" Width="100%" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" OnItemInserting="DetailsView1_ItemInserting" OnItemUpdating="DetailsView1_ItemUpdating">
        <Fields>
            <asp:BoundField DataField="AlbumID" HeaderText="Album ID :" InsertVisible="False" ReadOnly="True"
                SortExpression="AlbumID" />
            <asp:BoundField DataField="Name" HeaderText="Name :" SortExpression="Name" />
            <asp:TemplateField HeaderText="Description :" SortExpression="Description">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>' TextMode="MultiLine"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>' TextMode="MultiLine"></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="IsPublic" HeaderText="Is Public :" SortExpression="IsPublic" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" InsertText="Save" NewText="Add" />
        </Fields>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="Gainsboro" />
        <FieldHeaderStyle Font-Bold="True" HorizontalAlign="Right" Width="12%" Wrap="False" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        DeleteCommand="DELETE FROM [Albums] WHERE [AlbumID] = @AlbumID" InsertCommand="INSERT INTO [Albums] ([Name], [Description], [IsPublic]) VALUES (@Name, @Description, @IsPublic)"
        SelectCommand="SELECT [AlbumID], [Name], [Description], [IsPublic] FROM [Albums] ORDER BY [Name]"
        UpdateCommand="UPDATE [Albums] SET [Name] = @Name, [Description] = @Description, [IsPublic] = @IsPublic WHERE [AlbumID] = @AlbumID">
        <DeleteParameters>
            <asp:Parameter Name="AlbumID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="IsPublic" Type="Boolean" />
            <asp:Parameter Name="AlbumID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="IsPublic" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    <asp:Label ID="lblMsg" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="Red"></asp:Label>
</asp:Content>

