Joe Smith
Joe Smith

Reputation: 23

Combobox displaying duplicate items

I have a combo box that I am binding from a sql server database. I am binding one column from the database into the combo box. The problem is that I get the same item showing up in there several times. I am querying from a stored procedure. Let me know if there is anything obvious that I am missing. Thanks

public void BindComboBox()
{
   _dsinventory = new DataSet();
   _dsinventory = dbAccess.ExecuteQuery(InventoryOutputQuery.ComboBox_Type());
   cmbType.ItemSource = _dsinventory.Tables[0].DefaultView;
   cmbType.DisplayMemberPath = _dsinventory.Tables[0].Columns[Type].ToString();
}

Upvotes: 2

Views: 1121

Answers (2)

Raj Jayaswal
Raj Jayaswal

Reputation: 478

DISTINCT should only be used when you are sure that the query is all fine.

Double check the query you are using, and then go for DISTINCT.

Upvotes: 0

Pranay Rana
Pranay Rana

Reputation: 176896

try distinct keyword in you select query

 Select distinct columnname form table

Upvotes: 2

Related Questions