<%@ Page Language="VB" MasterPageFile="~/day02/MyMaster.master" Title="DataListコントロール" Theme="Spring" %>

<script runat="server">

    Protected Sub list_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If Session(list.SelectedValue) Is Nothing Then
            Session(list.SelectedValue) = 1
        Else
            Session(list.SelectedValue) += 1
        End If
    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="cph" Runat="Server">
    <asp:DataList ID="list" runat="server" Caption="商品情報" DataKeyField="isbn"
        DataSourceID="sds" OnSelectedIndexChanged="list_SelectedIndexChanged"
        RepeatColumns="2">
        <ItemTemplate>
            <asp:Image ID="Image1" runat="server" Height="150px" ImageAlign="Left" ImageUrl='<%# "http://www.wings.msn.to/books/" & Eval("isbn") & "/" & Eval("isbn") & ".jpg" %>'
                Width="110px" />
            <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>'></asp:Label>
            <br />
            ISBN
            <asp:Label ID="isbnLabel" runat="server" Text='<%# Eval("isbn") %>'></asp:Label><br />
            <asp:Label ID="priceLabel" runat="server" Text='<%# Eval("price", "{0:#,###円}") %>'></asp:Label>（税込）<br />
            <asp:Label ID="publishedLabel" runat="server" Text='<%# Eval("published", "{0:yyyy年MM月dd日}") %>'></asp:Label>配本<br />
            CD-ROM：<asp:Label ID="cdromLabel" runat="server" Text='<%# Eval("cdrom") %>'></asp:Label><br />
            <asp:Button ID="btnCart" runat="server" CommandName="Select" Text="カートに入れる" /><br />
        </ItemTemplate>
    </asp:DataList><asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB %>"
        SelectCommand="SELECT [isbn], [title], [price], [published], [cdrom] FROM [Book] ORDER BY [isbn]">
    </asp:SqlDataSource>
    <asp:HyperLink ID="link" runat="server" NavigateUrl="~/day06_7/GridView.aspx">購入ページへ</asp:HyperLink>
</asp:Content>

