I am building a form application for ordering phones. I have a drop down list which needs to have addresses of different stores. The address is stored in a MSSQL database where state,city,street and zip code are different columns in the table store. I am having trouble with getting the drop down list to show state,city,street instead of wanted data i get System.DataRowView in the drop down list as a option. I tried just requiring city or state and it works and shows the correct data.
Is there a way of getting all three informations(state,city,street) or should i just alter the sql table to contain this data in one column?
Here is the code:
try
{
SqlConnection connection = getConnection();
connection.Open();
SqlCommand sc = new SqlCommand("select state,city,street,sotreID from store", connection);
SqlDataReader reader;
reader = sc.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("street", typeof(string));
dt.Columns.Add("storeID", typeof(int));
dt.Load(reader);
prodavnicaCombo.ValueMember = "storeID";
prodavnicaCombo.DisplayMember = "state,city,street"; //the troublsome line is here
prodavnicaCombo.DataSource = dt;
connection.Close();
}
catch (Exception err)
{
MessageBox.Show("Exception: " + err.Message);
}