Populate ListBox control from two different tables?

Hi, I populate ListBox control from two different tables, the problem that I'm facing is how can I know when I retrieve the items from ListBox which one is belong to a partticular table because ListBox's items only have text and value it cannot take another third parameter that I can use to know if that item belong to a particular table, any suggesstion?
Who is Participating?
Jorge PaulinoIT Pro/DeveloperCommented:
Do you fill the values manually ?
You can add an extra sign to your value member to identify if belongs to one or another.
Example, for the ID 123 you can use TA123 and TB123. This way you know that the first two chars identify the table.
Abdu_AllahAuthor Commented:
Actually I thought about something like that but isn't there any other direct way?
Abdu_AllahAuthor Commented:
By the way I'm populate them like this:
lstbx.DataSource = objReader
lstbx.DataTextField = "item"
lstbx.DataValueField = "id"
So I do not think it's possible to add chatacters to the id column unless there is a way to do that in the SQL, here is my SQL statment just in case:

SELECT [user].user_id AS id,[user].Full_Name AS item FROM [user] UNION SELECT gr.group_id AS id,gr.Name AS item FROM [group] AS gr;

Open in new window

Jorge PaulinoIT Pro/DeveloperCommented:
You can use another control to do that, like listview or gridivew, and that way you can add an extra column and hide it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.