Hi,
I have a page with 3 dropdown lists on them.
1)status
2)project
3)subproject
What I would like to do is, when the user selects a status in the first dropdownlist I want the second to comeback to show all the projects that have that status. When the user then picks a project I want the third to comeback with a list of subprojects that belong to the project.
I thought that having an autopostback event set to true on 1 and 2 would help me to acheive the desired result.
However, it seems to work for the first 2 dropdownlists and then fails when I try to use the same logic for the 3rd dropdown list.
The code is as follows:
Can anyone see what I am doing wrong?
Any insights would be much appreciated.
SonD
I have a page with 3 dropdown lists on them.
1)status
2)project
3)subproject
What I would like to do is, when the user selects a status in the first dropdownlist I want the second to comeback to show all the projects that have that status. When the user then picks a project I want the third to comeback with a list of subprojects that belong to the project.
I thought that having an autopostback event set to true on 1 and 2 would help me to acheive the desired result.
However, it seems to work for the first 2 dropdownlists and then fails when I try to use the same logic for the 3rd dropdown list.
The code is as follows:
Code:
If Not Page.IsPostBack Then
'--get statuses
strSQL = "SELECT StatusText, StatusID FROM tblStatus WHERE isDeleted=0 ORDER BY SeqNo"
objCmd.CommandText = strSQL
objDR = objCmd.ExecuteReader()
selStatus.DataSource = objDR
selStatus.DataTextField = "StatusText"
selStatus.DataValueField = "StatusID"
selStatus.DataBind()
objDR.Close()
End If
'--get project names
strSQL = "SELECT ProjectName, ProjectID FROM tblProjects WHERE isSuperseded=0 "
If selStatus.SelectedValue > 1 Then
strSQL += " AND StatusID=" & selStatus.SelectedValue
End If
strSQL += " ORDER BY ProjectName"
lblEx.Text = strSQL & "<BR><BR>"
objCmd.CommandText = strSQL
objDR = objCmd.ExecuteReader()
selProjectName.DataSource = objDR
selProjectName.DataValueField = "ProjectID"
selProjectName.DataTextField = "ProjectName"
selProjectName.DataBind()
objDR.Close()
'--get sub projects names
strSQL = "SELECT SProjectName, SProjectID FROM tblSProjects WHERE isSuperseded=0 "
If selProjectName.SelectedValue > 0 Then
strSQL += " AND ProjectID=" & selProjectName.SelectedValue
End If
strSQL += " ORDER BY SProjectName"
lblEx.Text += strSQL & "<BR><BR>"
objCmd.CommandText = strSQL
objDR = objCmd.ExecuteReader()
selSProjectName.DataSource = objDR
selSProjectName.DataValueField = "SProjectID"
selSProjectName.DataTextField = "SProjectName"
selSProjectName.DataBind()
objDR.Close()
Can anyone see what I am doing wrong?
Any insights would be much appreciated.
SonD