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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Urgent Help Please Anyone!

Status
Not open for further replies.

ebarratt

Programmer
Apr 10, 2002
53
0
0
US
Hi all,

I am using a backend sql2000 db to store information. I have a table with 2 rows in it. The second column(YSItemNumber) has the value 1 for the first row and the value 2 for the second row. When this code below is executed the dropdownlist(lstYSItemNumber) has 2 options both with the value and text properties equal to 2. For the life of me I can't figure out why lstYSItemNumber doesn't have option one with the value and text equal to 1 and option 2 of lstYSItemNumber have the value and text equal to 2. Could anyone evaluate the code below and explain to me why this is occuring?

Dim dbDRUserYardSales As SqlDataReader
dbDRUserYardSales = dbCmd.ExecuteReader
If dbDRUserYardSales.Read Then
Dim intYSItemNumber As Integer
Dim newlistitem As New ListItem()
intYSItemNumber = dbDRUserYardSales.GetInt32(1)
newlistitem.Value = intYSItemNumber
newlistitem.Text = intYSItemNumber
newlistitem.Selected = True
lstYSItemNumber.Items.Add(newlistitem)
While dbDRUserYardSales.Read
intYSItemNumber = dbDRUserYardSales.GetInt32(1)
newlistitem.Value = intYSItemNumber
newlistitem.Text = intYSItemNumber
newlistitem.Selected = False
lstYSItemNumber.Items.Add(newlistitem)
End While

This would be a tremendous help to me if an expert can take the time to explain what's going on.


Errol *** Any suggestions to my asp.net site would be great if your bored!
 
Set the dropdownlist data source equal to the reader and the dataTextField and DataValueField equal to the fields that you want then just call the databind method.


That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top