In my project, I’m trying to populate ComboBox from DataSet. I succeeded in populating but the values inside the ComboBox are not distinct (Because it shows the values present in DataSet). I cant bind the ComboBox to DataSet because I’m adding “Select” text at first of populating the values.
ComboBox --> cmb
DataSet --> ds
DataSet Column Name --> value(string)
Here is my code:
cmb.Items.Clear();
cmb.Items.Add("Select");
for (int intCount = 0; intCount < ds.Tables[0].Rows.Count; intCount++)
{
cmb.Items.Add(ds.Tables[0].Rows[intCount][value].ToString());
}
cmb.SelectedIndex = 0;
How would I allow distinct values (or restrict duplicate values) inside the ComboBox?
1 Answer