TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aman Jen
NA
141
40.5k
Populating One Dropdownlist with selection of other DropDown
Jul 22 2013 7:17 AM
Hi, I am trying to Populating One Dropdownlist with selection of other DropDownlist control .
can't understand what is goin wrong..coz nothing is happening , just first is working well, i.e 1st Dropdown is binding data sucessfully but 2nd part isn't working...plz help...
Here's my code...
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
Public Sub boundDp()
cmd.Connection = cn
cmd.CommandText = "Select * From Acct_Sum"
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
DPA1.DataSource = dt
DPA1.DataTextField = "Loan_code"
DPA1.DataValueField = "Loan_code"
DPA1.DataBind()
DPA1.Items.Insert(0, "Select Item Here")
End Sub
Public Sub Shw_data()
cmd.Connection = cn
cmd.CommandText = "Select * From Acct_Sum Where Loan_code=@Loan_code"
cmd.Parameters.AddWithValue("@Loan_code", DPA1.SelectedItem.Value)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
TextBox1.Text = dr.Item("Bor_Name").ToString
TextBox2.Text = dr.Item("coBor_Name").ToString
End If
End Sub
Public Sub shw_data2()
cmd.Connection = cn
cmd.CommandText = "Select Loan_code From Acct_Sum2 Where Loan_code=@Loan_code"
cmd.Parameters.AddWithValue("@Loan_code", DPA2.SelectedItem.Value)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
DPA2.DataSource = dt
'DPA2.DataTextField = "chk_Num"
DPA2.DataValueField = "Loan_code"
DPA2.DataBind()
DPA2.Items.Insert(0, "Select Sub Item")
End Sub
Private Sub DPA2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DPA2.SelectedIndexChanged
cn.Open()
shw_data2()
cn.Close()
End Sub
Note...I have two tables...Acct_Sum and Acct_Sum2 with Unique ID=Loan_code
Thnx....
Reply
Answers (
3
)
autocomplete textbox in asp.net using database
MVC Get view values in controller