Asp.net 选择索引已更改且不';行不通

Asp.net 选择索引已更改且不';行不通,asp.net,vb.net,Asp.net,Vb.net,我现在有一个小问题困扰着我。我有5个动态填充的Dropbox: 日期 月(信) 年 数字日期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("

我现在有一个小问题困扰着我。我有5个动态填充的Dropbox:

  • 日期
  • 月(信)
  • 数字日期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>
    
    
    1.
    ...
    26
    27
    28
    29
    30
    31
    一月
    ...
    十一月
    十二月
    01
    02
    ....
    29
    30
    31
    01
    ....
    11
    12
    
    请添加ASP代码更新面板上是否有触发器?发布您的ASPX标记,否则我们将无法提供太多帮助。已发布。我没有触发器。因为即使没有触发器,它也能正常工作