<%@ Page Language="VB" MasterPageFile="~/day02/MyMaster.master" Title="簡易スケジュール帳" %>
<%@ Import Namespace="System.Data" %>

<script runat="server">

    Protected Sub cal_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)
        sds.SelectParameters.Clear()
        sds.SelectParameters.Add("sdate", e.Day.Date.ToString("yyyy/MM/dd"))
        Dim reader As IDataReader = sds.Select(DataSourceSelectArguments.Empty)
        Do While reader.Read()
            Dim ltrCr As New LiteralControl("<br />")
            Dim link As New HyperLink()
            link.NavigateUrl = "Details.aspx?sid=" & reader.GetInt32(0)
            link.Text = reader.GetString(2) & "&nbsp;" & reader.GetString(1)
            e.Cell.Controls.Add(ltrCr)
            e.Cell.Controls.Add(link)
        Loop
    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="cph" Runat="Server">
    <br />
    <asp:Calendar ID="cal" runat="server" BackColor="#FFFFCC" BorderColor="#FFCC66"
        BorderWidth="1px" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
        ForeColor="#663399" Height="375px" ShowGridLines="True" Width="500px" OnDayRender="cal_DayRender">
        <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
        <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
        <SelectorStyle BackColor="#FFCC66" />
        <OtherMonthDayStyle ForeColor="#CC9966" />
        <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
        <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
        <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
    </asp:Calendar>
    <asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB %>"
        DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:MyDB.ProviderName %>"
        SelectCommand="SELECT sid, subject, stime FROM Schedule WHERE (sdate = @sdate)">
        <SelectParameters>
            <asp:Parameter Name="sdate" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

