Hello
i have 2 DropdownList in my asp project and the first one is populated from SQL DB and the other one is populated from SQL DB but based on the selected value from the first one .
the problem is when i select the value from the second DropdonList and click on save i got nothing , the selected item is nothing
Note : both of DropdownList are Located into Repeater Control
To Populate DropDownList i use the following :
Dim dr As System.Data.SqlClient.SqlDataReader
Dim iListItem8 As New ListItem
iListItem8.Value = -1
iListItem8.Text = ""
cmbFinish.Items.Add((iListItem8))
dr = FinishType.AS_GetAllFinishType("ID")
While dr.Read
Dim iListItem88 As New ListItem
iListItem88.Value = dr("ID")
iListItem88.Text = dr("FinishCode") & " - " & dr("Description")
cmbFinish.Items.Add((iListItem88))
End While
dr.Close()
'*************************************************
Protected Sub cmbFinish_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim cmbFinish As DropDownList = CType(sender, DropDownList)
Dim currentRow As RepeaterItem = CType(cmbFinish.NamingContainer, RepeaterItem)
Dim cmbColor As DropDownList = CType(currentRow.FindControl("cmbColor"), DropDownList)
If ((Not (cmbFinish) Is Nothing) AndAlso ((cmbFinish.SelectedIndex > 0) AndAlso (Not (cmbColor) Is Nothing))) Then
Dim FinishID As String = cmbFinish.SelectedValue
Dim dr As System.Data.SqlClient.SqlDataReader
Dim iListItem9 As New ListItem
iListItem9.Value = -1
iListItem9.Text = ""
cmbColor.Items.Add((iListItem9))
dr = FinishColor.AS_GetAllFinishColorByFinishTypeID(FinishID)
While dr.Read
Dim iListItem99 As New ListItem
iListItem99.Value = dr("ID")
iListItem99.Text = ("ColorCode") & " - " & dr("Description")
cmbColor.Items.Add((iListItem99))
End While
dr.Close()
ElseIf (Not (cmbColor) Is Nothing) Then
cmbColor.Items.Clear()
End If
End Sub