I want to put on DataTextField more than 1 item from database (surname and name). How can I do this?
Of course, DataTextField="surname + name" doesn’t work, but is there any possibility to put together this 2 items?
There is my code:
<asp:DropDownList runat="server" ID="dllSpecialist" DataValueField="iduserspecialist" DataTextField="surname" AutoPostBack="true" OnSelectedIndexChanged="dllSpecialist_IndexChanged" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="0"></asp:ListItem>
</asp:DropDownList>
code behind:
if (!IsPostBack)
{
dllSpecialist.DataSource = tUserSpecialistBO.getAllSpecialist();
dllSpecialist.DataBind();
(..)
}
sql method:
public static DataSet getAllSpecialist()
{
sql = "select * from tuserspecialist where del='false' and name!=''";
return SQLTools.getDataSet(sql);
}
Change your SQL statement:
Then change your property to specify the new data item: