I would like to populate a listbox with multiple columns of data retrieved by a query.

I am using the Listbox.DataTextField = "SpaceID" to get one value but can't seem to append others using lines like Listbox.DataTextField = "SpaceID" & " " & "SpaceName"

Is there a way to do this?

it is solved? if solved please post the answer. so we can learn together. :)

Yes, it's solved.

I decided to concatenate through my SQL statement so I was able to view multiple columns together, as one. Not so much a solution as a workaround, but no one had replied, so I was never sure if there was an easy listbox property change.

I had the same problem and solved it by reading this topic. I like to see explicit but brief answers so here is my example.

SQL that combines the SPID and name field as an expression called name

select SPID, (convert(nvarchar(6), SPID) + ' ' + [name]) as [name] from SPIDS

VB that displays the name expression for the text and the SPID for the value

<asp:DropDownList ID="OSPSPID" runat="server" DataSourceID="SqlDataSource7"
                         DataTextField="name" DataValueField="SPID">
</asp:DropDownList>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.