anniemeerkat
New Member
Is there a way to assign more than one field to this? Like lastname, firstname. I can get around this by combining these fields in sql. But it would be nice to have the flexiblity in code. By the way is there any easy way to search this forum for keywords?As far as I know there is no way to do this. The DataTextField is a single string set to a single field. Your best bet is to do it in SQL, that is how I have been doing it. There is another way to do it using a sqldatareader and manually adding listitems, but the sql way is most likely better on performance. Here is a link to both methods:<BR>http://www.aspalliance.com/aldotnet/examples/doublecolumnddl.aspxI cant remember who first posted it, but this works.<BR>The new column allow concatenation, LangID and Lang are strings...<BR><BR> DataSet temp = <BR> SqlHelper.ExecuteDataset(ConnectionString,<BR> CommandType.StoredProcedure, <BR> "LanguageList");<BR> DataColumn myDC = new DataColumn("TESTCOL",String.Empty.GetType(),"LanguageID + ' --- ' + LanguageName");<BR> temp.Tables[0].Columns.Add(myDC);<BR> LanguageDropDownList.DataSource = temp;<BR><BR> LanguageDropDownList.DataTextField = "TESTCOL";<BR> LanguageDropDownList.DataValueField= "LanguageID";<BR> LanguageDropDownList.DataBind();<BR>