I Want To bind my dropdownlist with two value using some separator just [like ‘-‘ or ‘/’] in .net 3.5.
qry = "SELECT CityName, MasterState.StateName FROM MasterCity INNER JOIN "+
"MasterState ON MasterCity.StateID = MasterState.StateID order by CityName";
DropCity.DataMember = "DeafultView";
//DropCity.DataTextField = "CityName";
//DropCity.DataValueField = "CityName";
DropCity.DataTextFormatString = "{0} - {1}";
DropCity.DataTextField = "CityName,StateName";
DropCity.DataSource = dt;
DropCity.DataBind();
DropCity.Items.Insert(0, "-Select-");**
I did it but it gives error
DataBinding: ‘System.Data.DataRowView’ does not contain a property with the name ‘CityName,StateName’.”}
How can i do this?
DataTextFieldwill look for columnCityName,StateNameand it doesn’t exist.May be you can change your query like this