i want to set data source of one combo box to one column of table and this combo box is one of gridview column my code is :
DataTable p = new System.Data.DataTable();
p = selectcolor();
(dataGridView1.Columns[4] as DataGridViewComboBoxColumn).DataSource = p;
private DataTable selectcolor()
{
DataTable k = new System.Data.DataTable();
try
{
string str = "Data Source=C:\\Documents and Settings\\almas\\Desktop\\BazarKhodro\\khodro.sdf";
Qconnection.ConnectionString = str;
Qcommand.Connection = Qconnection;
string commandText = "select color from foroosh";
Qcommand.CommandText = commandText;
Qcommand.CommandType = CommandType.Text;
SqlCeDataAdapter a = new SqlCeDataAdapter();
a.SelectCommand = Qcommand;
a.Fill(k);
Qconnection.Open();
Qconnection.Close();
return k;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
return k;
}
}
after runing i see the content of p but content of combobox is:
System.Data.DataRowView
pls help me