Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList and Textbox 1

Status
Not open for further replies.

BDW1969

IS-IT--Management
Aug 29, 2002
43
US
I am new to asp.net so any help would appreciated!

What I am try do is show multiple values in the dropdown, once selected it populates the dropdown with a company name and also populates textboxes. He is my code so far.

Sub FIllInsuredDropDownList()
Dim sMasterClaim As String = "Select Company, ID, Company & ' ' & ID as FirstID From TblPolicyTable Order By COmpany"

Dim objComm As New SqlClient.SqlCommand(sMasterClaim, DBConn)
Dim objReader As SqlClient.SqlDataReader = Nothing

DBConn.Open()
objReader = objComm.ExecuteReader
sdaPolicy.SelectCommand = objComm
ddlInsured.DataSource = objReader
ddlInsured.DataTextField = "FirstID"
ddlInsured.DataValueField = "ID"
ddlInsured.DataBind()
DBConn.Close()
End Sub

Private Sub ddlInsured_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlInsured.SelectedIndexChanged

DBConn.Open()
Dim sPop As String = "SELECT Company, InsuranceCo, Policy_ID, ID, PolicyNumber FROM TblPolicy WHERE ID LIKE ddlInsured.SelectedItem.Value"

Dim objCommand As New SqlClient.SqlCommand(sPop, DBConn)
sdaPolicy.SelectCommand = objCommand

sdaPolicy.Fill(DsNClaim1)
txtInsCo.DataBind()
txtPolicyID.DataBind()
txtPolicyNumber.DataBind()

DBConn.Close()

End Sub
 
Code:
txtInsCo.DataBind()
        txtPolicyID.DataBind()
        txtPolicyNumber.DataBind()
You don't have to DatBind to each textbox. If you are just returning values from a database to a few textboxes then consider using a DataReader. There are lots of examples on this forum if you search for them.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Just to help you find a starting point on the Datareader, I found the link to thread855-984794.

Hope this helps.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top