1

我创建了一个动态下拉列表,下拉列表的数量等于所选月份的总天数。

我已将所有下拉列表放入,asp:table但我无法获取数据表单下拉列表,也无法触发selectedindexchange事件。

我的代码如下

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Table2.Rows(0).Cells(0).Text = v1_drop_month.SelectedItem.Text
        helper.return_month(v1_drop_month.SelectedItem.Text)

        i = 1
        For row = 0 To 6
            For cell = 1 To 7

                Dim dd As New DropDownList


                Dim label As New Label
                If row = 0 And cell = 1 Then
                    Table2.Rows(row).Cells(cell - 1).BackColor = Drawing.Color.Teal
                ElseIf row = 1 Then
                    Table2.Rows(1).Cells(cell - 1).Font.Size = 14
                    Table2.Rows(1).Cells(cell - 1).HorizontalAlign = HorizontalAlign.Center
                    Table2.Rows(1).Cells(cell - 1).ForeColor = Drawing.Color.White
                    Table2.Rows(1).Cells(cell - 1).BackColor = Drawing.Color.Black

                ElseIf row >= 2 Then
                    If i <= helper.month_num Then

                        dates = helper.Month_no & "-" & i & "-" & v1_drop_month.SelectedItem.Text.Substring(4, 4)
                        day = New DateTime(v1_drop_month.SelectedItem.Text.Substring(4, 4), helper.Month_no, i)

                        If Table2.Rows(1).Cells(cell - 1).Text = day.DayOfWeek.ToString() Then
                            label.Text = i
                            label.Font.Size = 20
                            label.ForeColor = Drawing.Color.Red
                            Table2.Rows(row).Cells(cell - 1).HorizontalAlign = HorizontalAlign.Right
                            label.ID = row & "-" & cell

                            Table2.Rows(row).Cells(cell - 1).Controls.Add(label)
                            If day.DayOfWeek.ToString() <> "Sunday" Then
                                label.ForeColor = Drawing.Color.Blue

                                Table2.Rows(row).Cells(cell - 1).Controls.Add(dd)
                                dd.ID = "dd" & row & "-" & cell

                                sql = String.Empty
                                sql = "select distinct route_number from fr_route where territory='" & v1_drop_territory.SelectedItem.Text & "' and state='" & v1_drop_state.SelectedItem.Text & "' and hq='" & v1_drop_hq.SelectedItem.Text & "'"
                                helper.dropdown_change(sql, "route_number", dd)

                                Table2.Rows(row).Cells(cell - 1).BackColor = Drawing.Color.SkyBlue
                                dd.BackColor = Drawing.Color.Khaki
                                Table2.Rows(row).Cells(cell - 1).Height = 50


                            End If

                            i = i + 1
                        End If
                    Else

                    End If
                End If
            Next
        Next
        v1_but_save.Visible = True
        v1_but_reset.Visible = True
        v1_but_send.Visible = True

    End Sub

我已经用于asp:table显示下拉菜单

4

1 回答 1

0

为下拉列表启用“AutoPostBack=True”

于 2013-01-08T12:01:31.010 回答