Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

OK, I put my database info in a listbox....I would like to be able to select the item and get the displaymember and valuemember info from it. It seems that all i can retrieve is an index number, and if that is all that i can get then what is a good way i could go about using the index # to retrieve access to the data. :confused:

 

------------------------------------------------------

Dim dc As New OleDb.OleDbConnection(strProvider)

dc.Open()

Dim strSQL As String = "SELECT * FROM Discreps WHERE Job_ID='0'"

Dim mydc As New OleDb.OleDbCommand(strSQL, dc)

Dim myadp As New OleDb.OleDbDataAdapter(mydc)

dsJobDiscreps.Clear()

myadp.Fill(dsJobDiscreps)

dc.Close()

lstDesc.DataSource = dsJobDiscreps.Tables(0)

lstDesc.DisplayMember = "Discrep_ID"

lstDesc.ValueMember = "JobDiscrep_ID"

-----------------------------------------------------

 

Thank for the help in advance. I just think I have had way too much Dr. Pepper this morning :D

Posted

Use the SelectedItem and the SelectedValue to retrieve the info you want...

 

You probably have tryed this but it didn't give you anything you could use...

It's because of a bug on the ListBox that gives you a DataRowView object instead of the proper data...

 

This can be overcomed changing the order of the lines you use to set the binding on the ListBox.

Change the last 3 lines of your code to this and tell me if it fixed it.

lstDesc.DisplayMember = "Discrep_ID"
lstDesc.ValueMember = "JobDiscrep_ID"
lstDesc.DataSource = dsJobDiscreps.Tables(0)

Note that I just changed the position/order of the lines...

 

Alex :D

Software bugs are impossible to detect by anybody except the end user.
Posted

What is that MemberValue?? ValueMember?

 

ValueMember its the column name on the table that you want to bind to...

 

I'm not quite understanding your point... sorry...

Try to explain a little better, ok?

 

Alex :D

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...