EDN Admin
Well-known member
Hi,
Am using a combo box(drop-down)in gridview and am populating the second column in the griview using a SELECT query as shown in the code. Basically, users would map the fields using the values in the drop-down. How can I modify the code below so that if users select a value from the drop-down list, it doesnt show in the other drop-down lists as it is already selected? Thanks in advance!public void GV(DataTable table)
{
dataGridView1.DataSource = table.DefaultView.ToTable(false, "ColumnName");
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
SqlConnection conn = new SqlConnection ("server=dev;database=Test;Trusted_Connection=True");
conn.Open();
string query = "SELECT Customer FROM information_schema.columns WHERE TABLE_NAME = CM ";
SqlCommand cmd = new SqlCommand(query, conn);
DataTable t1 = new DataTable();
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
{
a.Fill(t1);
}
cmb.DataSource = t1;
cmb.ValueMember = "Customer";
dataGridView1.Columns.Add(cmb);
}
View the full article
Am using a combo box(drop-down)in gridview and am populating the second column in the griview using a SELECT query as shown in the code. Basically, users would map the fields using the values in the drop-down. How can I modify the code below so that if users select a value from the drop-down list, it doesnt show in the other drop-down lists as it is already selected? Thanks in advance!public void GV(DataTable table)
{
dataGridView1.DataSource = table.DefaultView.ToTable(false, "ColumnName");
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
SqlConnection conn = new SqlConnection ("server=dev;database=Test;Trusted_Connection=True");
conn.Open();
string query = "SELECT Customer FROM information_schema.columns WHERE TABLE_NAME = CM ";
SqlCommand cmd = new SqlCommand(query, conn);
DataTable t1 = new DataTable();
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
{
a.Fill(t1);
}
cmb.DataSource = t1;
cmb.ValueMember = "Customer";
dataGridView1.Columns.Add(cmb);
}
View the full article