0

我有一个小问题目前困扰着我。我有 5 个动态填充的保管箱:

  1. 日期
  2. 月(字母)
  3. 数字日期 5 数字月份。

我使用以下代码用当前日期值填充它们:

Dim CurYear As Integer = DatePart("yyyy", Now)
Dim CurDate As Integer = DatePart("d", Now)
Dim CurMonth As String = Format(Today.Date, "MMMM")
Dim CurDate2 As Integer = DatePart("d", Now)
Dim CurMonth2 As String = Format(Now, "MM") 

Dates.Text = CurDate
Monthe.Text = CurMonth
years.Text = CurYear
Month2.Text = CurMonth2
Dates2.Text = CurDate2  

比我有一个处理框 4 和 5 的更新面板。如果框 1 和 2 更改,他们应该更改索引。但它不起作用。

Protected Sub Months_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Months.SelectedIndexChanged
      Month2.SelectedIndex = Months.SelectedIndex
End Sub

Protected Sub Dates_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Dates.SelectedIndexChanged
    Dates2.SelectedIndex = Dates.SelectedIndex
End Sub

如果我不使用当前日期(代码示例 1)填充下拉框,它可以工作。如果我这样做, selectedIndexChanged 不会做出反应。可能的错误是什么?

asp标记:

<asp:DropDownList ID="Dates" runat="server" autopostback="true">
                          <asp:ListItem></asp:ListItem>
                          <asp:ListItem>1</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>

                        <asp:DropDownList ID="Months" runat="server" autopostback="true" >
                          <asp:ListItem></asp:ListItem>
                          <asp:ListItem>January</asp:ListItem>
                          ...
                          <asp:ListItem>November</asp:ListItem>
                          <asp:ListItem>December</asp:ListItem>
                        </asp:DropDownList>


                        <asp:DropDownList ID="years" runat="server" autopostback="true" >
                          <asp:ListItem></asp:ListItem>
                        </asp:DropDownList>


                        <asp:DropDownList ID="Dates2" runat="server" AutoPostBack="True">
                          <asp:ListItem></asp:ListItem>
                          <asp:ListItem>01</asp:ListItem>
                          <asp:ListItem>02</asp:ListItem>
                          ....
                          <asp:ListItem>29</asp:ListItem>
                          <asp:ListItem>30</asp:ListItem>
                          <asp:ListItem>31</asp:ListItem>
                        </asp:DropDownList>

                        <asp:DropDownList ID="Month2" runat="server" AutoPostBack="True">
                          <asp:ListItem></asp:ListItem>
                          <asp:ListItem>01</asp:ListItem>
                          ....
                          <asp:ListItem>11</asp:ListItem>
                          <asp:ListItem>12</asp:ListItem>
                        </asp:DropDownList>
4

0 回答 0