可以';t使我的日历在ASP.NET web窗体中正确显示

本文关键字:窗体 web NET 显示 ASP 日历 我的 可以 | 更新日期: 2023-09-27 18:03:42

我的webform中有两个下拉列表和一个日历控件。当我点击我的日历值时。它应该选择正确的值并将这些值放在我的下拉列表中,但在我选择它们之后,下拉列表中没有显示任何内容。ID值的名称正确。偶数处理程序已连线。我搞不清楚发生了什么。这是我用来将它们连接在一起的代码。

 protected void clnArrival_SelectionChanged(object sender, EventArgs e)
{
    ddlMonth.SelectedValue = clnArrival.SelectedDate.Month.ToString();
    ddlDay.SelectedValue = clnArrival.SelectedDate.Day.ToString();
}

这里是我的aspx代码

  <asp:Calendar ID="clnArrival" runat="server" Visible="true"       
  OnSelectionChanged="clnArrival_SelectionChanged">
         <TodayDayStyle BackColor="Blue" Font-Bold="True" ForeColor="White"  
         />
         <TitleStyle BackColor="Blue" Font-Bold="True" ForeColor="White" />
        <NextPrevStyle ForeColor="White" />
    </asp:Calendar>

编辑

此信息来自本应编辑的答案

<asp:DropDownList ID="ddlMonth" runat="server" Height="18px" Width="150px">
 </asp:DropDownList>
    <asp:DropDownList ID="ddlDay" runat="server" Width="173px">
 </asp:DropDownList>

可以';t使我的日历在ASP.NET web窗体中正确显示

    <asp:DropDownList ID="ddlMonth" runat="server" Height="18px"   
     Width="150px">
        <asp:ListItem Value="1">January</asp:ListItem>
        <asp:ListItem Value="2">February</asp:ListItem>
        <asp:ListItem Value="3">March</asp:ListItem>
        <asp:ListItem Value="4">April</asp:ListItem>
        <asp:ListItem Value="5">May</asp:ListItem>
        <asp:ListItem Value="6">June</asp:ListItem>
        <asp:ListItem Value="7">July</asp:ListItem>
        <asp:ListItem Value="8">August</asp:ListItem>
        <asp:ListItem Value="9">September</asp:ListItem>
        <asp:ListItem Value="10">October</asp:ListItem>
        <asp:ListItem Value="11">November</asp:ListItem>
        <asp:ListItem Value="12">December</asp:ListItem>
    </asp:DropDownList>
    <asp:DropDownList ID="ddlDay" runat="server" Width="173px">
        <asp:ListItem Value="1">1</asp:ListItem>
        <asp:ListItem Value="2">2</asp:ListItem>
        <asp:ListItem>3</asp:ListItem>
        <asp:ListItem>4</asp:ListItem>
        <asp:ListItem>5</asp:ListItem>
        <asp:ListItem>6</asp:ListItem>
        <asp:ListItem>7</asp:ListItem>
        <asp:ListItem>8</asp:ListItem>
        <asp:ListItem>9</asp:ListItem>
        <asp:ListItem>10</asp:ListItem>
        <asp:ListItem>11</asp:ListItem>
        <asp:ListItem>12</asp:ListItem>
        <asp:ListItem>13</asp:ListItem>
        <asp:ListItem>14</asp:ListItem>
        <asp:ListItem>15</asp:ListItem>
        <asp:ListItem>16</asp:ListItem>
        <asp:ListItem>17</asp:ListItem>
        <asp:ListItem>18</asp:ListItem>
        <asp:ListItem>19</asp:ListItem>
        <asp:ListItem>20</asp:ListItem>
        <asp:ListItem>21</asp:ListItem>
        <asp:ListItem>22</asp:ListItem>
        <asp:ListItem>23</asp:ListItem>
        <asp:ListItem>24</asp:ListItem>
        <asp:ListItem>25</asp:ListItem>
        <asp:ListItem>26</asp:ListItem>
        <asp:ListItem>27</asp:ListItem>
        <asp:ListItem>28</asp:ListItem>
        <asp:ListItem>29</asp:ListItem>
        <asp:ListItem>30</asp:ListItem>
        <asp:ListItem>31</asp:ListItem>
    </asp:DropDownList>
 protected void clnArrival_SelectionChanged(object sender, EventArgs e)
{
    ddlMonth.SelectedValue = clnArrival.SelectedDate.Month.ToString();
    ddlDay.SelectedValue = clnArrival.SelectedDate.Day.ToString();
}

这段代码应该可以工作,现在这两个下拉列表将显示正确的月份和日期,只需确保下拉列表的aspx值属性正确即可。