<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Artists.aspx.cs" Inherits="MyTunes.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            width: 302px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <div>

            <asp:Label ID="lblDebug" runat="server" Font-Bold="True" ForeColor="Red">SQL Database Binding Example - Artists with Template Column</asp:Label>

        </div>
    <div class="pageSelect">
        <table style="width: 100%">
            <tr>
                <td>
                <asp:Label ID="lblFilter" runat="server" Text="Artist Quick Search"></asp:Label>
                <asp:TextBox ID="txtArtistFilter" runat="server" 
                        ontextchanged="txtArtistFilter_TextChanged"></asp:TextBox>
                <asp:ImageButton ID="btnFilterGo" 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="ArtistGridView" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="artist_id" DataSourceID="MyTunesDatabase" AllowPaging="True" 
        AllowSorting="True" ondatabound="ArtistGridView_DataBound" PageSize="25" 
            onrowcommand="ArtistGridView_RowCommand">
    <Columns>
        <asp:BoundField DataField="artist" HeaderText="Artist" 
            SortExpression="artist" />
        <asp:TemplateField HeaderText="Album Count" SortExpression="artist_id">
            <EditItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("artist_id") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" 
                    CommandArgument='<%# Eval("artist_id") %>' CommandName="Album" 
                    Text='<%# DisplayAlbumCount(Eval("artist_id")) %>'></asp:LinkButton>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
        </asp:TemplateField>
    </Columns>
        <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" 
            PageButtonCount="25" />
</asp:GridView>
    
<asp:SqlDataSource ID="MyTunesDatabase" runat="server" 
    ConnectionString="<%$ ConnectionStrings:MyTunesConnectionString %>" 
    SelectCommand="ArtistSelectCommand" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</asp:Content>
