Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > using dataView
 

using dataView

DataSource of my ComboBox control is a dataView with the DataMember one of my table colomn. How can I have distinct values in my ComboBox.

thx
alexandra.dorneanu  Thursday, November 15, 2007 6:29 AM

Hi,

Check Mike's code

DataTable distinctTable = originalTable.DefaultView.ToTable( /*distinct*/ true);

HTH,
Suprotim Agarwal

-----
http://www.dotnetcurry.com
-----

Suprotim Agarwal  Thursday, November 15, 2007 9:31 AM

Hi,

Check Mike's code

DataTable distinctTable = originalTable.DefaultView.ToTable( /*distinct*/ true);

HTH,
Suprotim Agarwal

-----
http://www.dotnetcurry.com
-----

Suprotim Agarwal  Thursday, November 15, 2007 9:31 AM
Suprotim Agarwal  Thursday, November 15, 2007 9:33 AM

You can make it by Sql:

in the statement that create the view use the distinct keyworldbefor the column you want

for example :

Select distinct name fro, Employee

Fadi Nassri  Thursday, November 15, 2007 9:49 AM

Hi,

I agree to Fadi. That should be the way.

However I have made an assumption that alexandra has already tried that and still gets duplicate data.

If you want to go the sql way and have multiple columns, try this :

SELECT DISTINCT
Col1, Col2 FROM

MyTable

GROUP BY Col1, Col2
HAVING COUNT(*) > 1

HTH,
Suprotim Agarwal

-----
http://www.dotnetcurry.com
-----

Suprotim Agarwal  Thursday, November 15, 2007 10:11 AM

You can use google to search for other answers

Custom Search

More Threads

• Winforms Datagrid Control Sorting problem while drag-and-drop
• Async DataBinding / IBindingList
• Problems with row error text.
• Validate problem when use databinding
• custom control hosting in DataGridView Header
• adding new rows to already bound datagrid in frameowrk 1.1
• I try to use BindingNavigator to get current position in the table and move it to a new form
• scrolling in a DataGridView
• VB .Net 2003 DataSet
• DataGridView with RichTextBox Column