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!
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!