0

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?

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by lance.stine
0

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.

0

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>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.