<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Albums.aspx.cs" Inherits="MyTunes.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <asp:Label ID="lblDebug" runat="server" Text="SQL Database Binding Example - Albums with Template Column" 
            Font-Bold="True" ForeColor="Red"></asp:Label>
    </div>
    
    <div class="pageSelect">
        <table style="width: 100%">
            <tr>
                <td>
                <asp:Label ID="lblAlbumFilter" runat="server" Text="Album Quick Search"></asp:Label>
                <asp:TextBox ID="txtAlbumFilter" runat="server"></asp:TextBox>&nbsp;
                <asp:ImageButton ID="ImageButton1" runat="server" 
                        ImageUrl="~/App_Themes/Default/Images/rarrow.gif" 
                        onclick="btnFilterGo_Click" ToolTip="Run Search" />
                </td>
                <td style="text-align: center">
                    <asp:Label ID="lblPageInfo" runat="server" Font-Italic="True"></asp:Label>
                </td>
                <td align="right" class="style1" valign="middle">
        <asp:Label ID="lblPageSelect" runat="server" Text="Jump to:"></asp:Label>
        <asp:DropDownList
            ID="lstPageSelect" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="lstPageSelect_SelectedIndexChanged">
        </asp:DropDownList>
                </td>
            </tr>
        </table>
    </div>
    <asp:GridView ID="AlbumGridView" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="album_id" 
        DataSourceID="MyTunesDatabase" PageSize="25" 
    ondatabound="AlbumGridView_DataBound" onrowcommand="AlbumGridView_RowCommand">
        <Columns>
            <asp:BoundField DataField="album" HeaderText="Album" SortExpression="album" />
            <asp:TemplateField HeaderText="Artist" SortExpression="artist_id">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("artist_id") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" 
                        Text='<%# DisplayArtistName(Eval("artist_id")) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Song Count">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("album_id") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" 
                        CommandArgument='<%# Eval("album_id") %>' CommandName="Album" 
                        Text='<%# DisplaySongCount(Eval("album_id")) %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" 
            PageButtonCount="25" />
    </asp:GridView>
    <asp:SqlDataSource ID="MyTunesDatabase" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyTunesConnectionString %>" 
        SelectCommand="AlbumSelectCommand" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
</asp:Content>
