i have a problem in dropdown :suppose i select id from dropdown then i want name of the employee is displayed matched with that id is displayed in textbox : i have use the following code

con = New SqlConnection(constr)
adpt = New SqlDataAdapter("select * from reg where f_name='" + DropDownList1.SelectedItem.Text.ToString + "' ", con)
ds = New DataSet
adpt.Fill(ds)
If ds.Tables(0).Rows.Count - 1 >= 0 Then
TextBox1.Text = ds.Tables(0).Rows(0).Item(11)
End If

Recommended Answers

All 2 Replies

arunasingh,

This is your 38th post and you post source code without bb code tags. I think you haven't read - How to use bb code tags?.

Wrap up source code with bb code tags.

the logic u r using is incorrect.
use a looping statement.
traverse each record of the data set using this loop.
inside the loop check for the matching id.
when its found u display that information in the text box and then u break out of the loop

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.