Just select only Name
and City
in dt
, so that you can do something like,
dgv_ClientDetail.DataSource = dt;
DataGridViewComboBoxColumn dgvCboColumn = new DataGridViewComboBoxColumn();
dgvCboColumn.Name = "Contacts";
dgvCboColumn.DataSource = dtContacts; //DataTable that contains contact details
dgvCboColumn.DisplayMember = "Name";
dgvCboColumn.ValueMember = "Id";
dataGridView1.Columns.Add(dgvCboColumn);
EDIT:
dgv_ClientDetail.DataSource = new DataView(dt)
.ToTable(true, new string[] { "Name", "City" });
DataGridViewComboBoxColumn dgvCboColumn = new DataGridViewComboBoxColumn();
dgvCboColumn.Name = "Contacts";
dgv_ClientDetail.Columns.Add(dgvCboColumn);
foreach (DataGridViewRow row in dgv_ClientDetail.Rows)
{
DataGridViewComboBoxCell cboContacts = (DataGridViewComboBoxCell)
(row.Cells["Contacts"]);
cboContacts.DataSource = //Get the contact details of a person,
//using his Name or Id field (row.Cells["Name"]);
cboContacts.DisplayMember = "Name"; //Name column of contact datasource
cboContacts.ValueMember = "Id";//Value column of contact datasource
}
Hope this helps...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…