About drop down list

R

Ravindra

Hi all,
i want to retrieve the values from database and edit them. I have drop down
list for gender. item :male and female.here is the code.
con.Open()

cmd = New SqlCommand("select * from customers where fullname='" & fname &
"'", con)

Dim dr As SqlDataReader

dr = cmd.ExecuteReader

While dr.Read

Me.txtName.Text = dr.Item("Fullname")

Me.txtAddress.Text = dr.Item("address")

Me.txtAreaCode.Text = dr.Item("areacode")

Me.txtTelePhone.Text = dr.Item("telephone")

Me.txtComments.Text = dr.Item("comments")

Me.txtEmail.Text = dr.Item("email")

Me.txtVisits.Text = dr.Item("novisits")

Me.ddlPrice.SelectedItem.Value = dr.Item("price")

Me.ddlGender.SelectedItem.Text = dr.Item("gender")

Me.ddlAntiVirus.SelectedItem.Text = dr.Item("antivirus")

Me.txtCity.Text = dr.Item("city")

Me.ddlstatus.SelectedItem.Text = dr.Item("status")

End While

con.Close()

but i am getting the error, i.e in gender drop down i could see female
,female. There is no male in list.So plz clarify this



regards

ravindra
 
M

Mark Rae

Me.ddlGender.SelectedItem.Text = dr.Item("gender")
but i am getting the error, i.e in gender drop down i could see female
,female. There is no male in list.So plz clarify this

That's because you are changing the visible text of the selected item in the
dropdown - you need to be using SelectedValue instead
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top