PDA

View Full Version : Put two values in the Dropdownlist Datatextfield HOW?


maxvee8
02-12-2008, 08:10 PM
hi ive got a dropdownlist populated from a sql database but how do i put two value in teh DatTextField...

atm it is staffNo but say i want StaffNo + Fname + LName to be displayed

how do i do this?

<asp:DropDownList ID="Module" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="staffNo" DataValueField="staffNo" OnSelectedIndexChanged="Module_SelectedIndexChanged">

thanks max:confused:

skillzdx
02-16-2008, 05:27 AM
why dont you contatonate the fields duiring your query so that it will return it in one field

EricaStar
02-16-2008, 07:33 PM
I would agree with skillzdx. I don't remember what the syntax in SQL, but in MySql (it's probably similar) it is:

Select concat(firstname, ' ',lastname) as FullName from tblUsers

Then in your code reference FullName, which display like this: "Firstname Lastname".