asp.net动态创建n个dropdownlist并获取所选索引值
我已经创建了一个动态下拉列表,下拉列表的数量等于所选月份的总天数 我已经把所有的下拉列表都放到了asp.net动态创建n个dropdownlist并获取所选索引值,asp.net,vb.net,Asp.net,Vb.net,我已经创建了一个动态下拉列表,下拉列表的数量等于所选月份的总天数 我已经把所有的下拉列表都放到了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
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
Protected Sub Button1\u Click(ByVal sender作为对象,ByVal e作为System.EventArgs)处理按钮1。单击
表2.行(0).Cells(0).Text=v1\u drop\u month.SelectedItem.Text
helper.return\u month(v1\u drop\u month.SelectedItem.Text)
i=1
对于行=0到6
对于单元格=1到7
Dim dd作为新的下拉列表
将标签变暗为新标签
如果行=0,单元格=1,则
表2.行(行).单元格(单元格-1).背景色=Drawing.Color.Teal
如果行=1,则
表2.行(1).单元格(单元格-1).Font.Size=14
表2.行(1).单元格(单元格-1).水平对齐=水平对齐.居中
表2.行(1).单元格(单元格-1).前景色=Drawing.Color.White
表2.行(1).单元格(单元格-1).背景色=Drawing.Color.Black
如果行>=2,则
如果我为dropdownlist启用“AutoPostBack=True”我尝试过使用AutoPostBack=True,但它不起作用,甚至在使用autopost back之后,所有dorp down都是不可见的。。。。。。。。。。。