Question : fill datagrid based on drop down box values

What I have are 3 drop downs on a page, and for each drop down it fills the next drop down in line but each one of them produces a different value that needs to be pushed to the sql statement to render a different datagrid, howerver I ahve not been able to get it to work.
Here the logic I am trying to produce.
If the first drop down is picked it should fill the next Drop down which is does and produce teh datagrid with the sql where statement.

When the second one is picked it should fill 3rd drop down, it does but should produce a different datagrid fill.

When the third is picked it should produce another datagrid fill.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
Private Sub FillDataGrid() 
        Dim DeployId As String = Convert.ToInt16(ddlDeployment.SelectedValue.ToString())
        pnlDatagrid.Visible = True
        Dim theCounter As Integer
        Dim SqlWhere As String
 
 
        If CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue = Nothing And ddlUic.SelectedValue = Nothing Then
            SqlWhere = "ud.intMobilizationId = " & ddlDeployment.SelectedValue
        ElseIf CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue > "0" And ddlUic.SelectedValue = Nothing Then
            Dim BnId As String = ddlBn.SelectedValue.ToString
            SqlWhere = "ud.strAAUic = " & ddlBn.SelectedValue
        ElseIF CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue > "0" And Cint(ddlUic.SelectedValue)> 0  Then
        SqlWhere = "ud.intUnitMobId = " & ddlUic.SelectedValue
 
        End If
 
        sql = "Select Distinct intPermTaskId, ud.strUic, pt.strTaskName, DateDiff(day, dtFound, Getdate()) as  Days_Old, pt.strName, pt.strProponent from tblPermTask as pt INNER JOIN " _
            & "tblSoldierFilters as uf on uf.intAssignedId = pt.intAssignedId INNER JOIN tblUnitDeployData as ud on ud.intUnitMobId = uf.intUnitMobid INNER JOIN tblUnitPersonnel as p " _
            & "on pt.intpositionId = p.intPositionId and pt.strSSN = p.strSSN where pt.dtCompleted IS NULL AND pt.intElevated = 1 AND pt.dtCompleteTask < getdate() AND (p.bitrefrad IS NULL " _
            & "AND p.bitRearDet IS NULL) AND " & SqlWhere & " Order by strTaskname, DateDiff(day, dtFound, Getdate()) desc"
 
        myDataTable = New DataTable
        myDataTable = getData(sql)
 
        myDataGrid.DataSource = myDataTable
        myDataGrid.DataBind()
 
    End Sub

Answer : fill datagrid based on drop down box values

Did you step through the code to see which If condition gets executed? We can then decide whether the problem is with If block or with the SQL query.
Random Solutions  
 
programming4us programming4us