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

ListBox value

Status
Not open for further replies.

chezealot9

Programmer
Jun 17, 2003
50
0
0
US
Hey Guys, I am using a listbox control and trying to get the value of selected item. Instead of giving me the value of the field which I had set as the DataValueField, I am getting the index of the row selected. Any ideas? Im using Me.Flag.Text = Me.ListBox1.SelectedValue.ToString().

I greatly appreciate any help!!
 
Me.Flag.Text = Me.ListBox1.SelectedItem.Value should do the trick

 
I tried it and its still only giving the index. I can get the actual text but not the value for some reason, what would make the value of the listbox not bind to it or whatever?
 
when your web page is loaded and your list box is populated; do a View Source Code and look at your values to see if things are binding...
 
It looks like it isn't, its just putting the index in as the value? What does that mean? Where is it switching it?
 
post your binding code....are you using vs.net?
 
FOund the error, somewhere along the line I was changing to a different query for the listbox and that query had a problem with it, thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top