读书人

请问Datagrid里面两个Dropdownlist连动

发布时间: 2012-02-05 12:07:15 作者: rapoo

请教Datagrid里面两个Dropdownlist连动!!!!
我在两个绑定列里分别放一个Dropdownlist
Private Sub TMTDataGrid1_TMTableDataGridItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TMTDataGrid1.TMTableDataGridItemDataBound
Dim drd As DropDownList
Dim drdtwo As DropDownList
Dim tmtdg As TMTableDataGrid
Dim middle As Integer
Dim dt As DataTable
Dim j As Integer
dt = New DataTable
tmtdg = Me.TMTDataGrid1.SubTMTableDataGrid
dt = tmtdg.MaintenanceDataTable

drd = CType(CType(e, DataGridItemEventArgs).Item.Cells(3).Controls(1), DropDownList)

If CType(e, DataGridItemEventArgs).Item.ItemIndex > = 0 Then
drd = CType(CType(e, DataGridItemEventArgs).Item.Cells(4).Controls(1), DropDownList)
drdtwo = CType(CType(e, DataGridItemEventArgs).Item.Cells(5).Controls(1), DropDownList)
middle = drdtwo.SelectedIndex
drd.SelectedIndex = middle

End If
end sub
drdtwo.SelectedIndex总是取的上一次选的值,取不到当前的值


[解决办法]
((DropDownList)item.FindControl( "DropDownList2 ")).SelectedIndex=DDL.SelectedIndex;

//这句

读书人网 >asp.net

热点推荐