How can I display two columns in the DropDownList in asp.net?
SqlDataSourceNamePeop.SelectCommand = "select name,forename from people";
DropDownListCaptain.DataTextField = "name";
Like this it displays only the names. But how can i display the names+forenames?
<asp:DropDownList ID="DropDownListPeople"
runat="server"
DataSourceID="SqlDataSourceNamePeop">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceNamePeop"
ConnectionString="xxxxx"
runat="server">
</asp:SqlDataSource>
The easiest way is to make your sql query like this:
then bind this custom property to your drop down list like this:
Let me know if it fixed your problem, thanks.