Follow the code below i have made some modifications to make it easier and work. I didnt verified connections etc.
1) Define two dropdown list like below
<asp:dropdownlist id="drp1" runat="server" onselectedindexchanged="drp1_SelectedIndexChanged" autopostback="true" datavaluefield="xyz" datatextfield="xyz" xmlns:asp="#unknown">
</asp:dropdownlist>
<asp:dropdownlist id="drp2" runat="server" datavaluefield="loan_code" datatextfield="loan_code" xmlns:asp="#unknown">
</asp:dropdownlist>
2)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
cn.Open()
boundDp()
cn.Close()
End If
End Sub
3)
Public Sub boundDp()
cmd.Connection = cn
cmd.CommandText = "Select xyz From Acct_Sum"
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
Dim dr As DataRow = dt.NewRow()
dr("xyz") = "Select Item Here"
dt.Rows.InsertAt(dr, 0)
drp1.DataSource = dt
drp1.DataBind()
End Sub
4)
Private Sub drp1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DPA2.SelectedIndexChanged
cn.Open()
cmd.Connection = cn
cmd.CommandText = "Select loan_code From Acct_Sum2 Where loan_code=@Loan_code"
cmd.Parameters.AddWithValue("@Loan_code", drp1.SelectedValue)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
Dim dr As DataRow = dt.NewRow()
dr("xyz") = "Select Sub Item Here"
dt.Rows.InsertAt(dr, 0)
drp2.DataSource = dt
drp2.DataBind()
cn.Close()
End Sub
Regards..:laugh: