SelecteIndex Changed不起作用

时间:2013-05-11 17:43:16

标签: asp.net vb.net

我有一个困扰我的问题。我有5个动态填充的dropbox:

  1. 日期
  2. 月(字母)
  3. 数字日期5数字月。
  4. 我使用以下代码用当前日期值填充它们:

    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>
    

0 个答案:

没有答案