Question : What is the best way to walk through a DataSource of a DevExpress XtraGrid to see if there are any duplicate values in the rows?

I have a XtraGrid control that I need to ensure there are no duplicate rows in...

I have attached a method to handled Validating_Editor event.  (See code).

The uniqueness of any row is defined by 3 columns.  I need to warn the User if any two rows are the same in those 3 columns (Product, SubProd, Type).

My educated guess is to walk through the rows and then "filtering" the dataset attached to the XtraGrid and seeing if any of the results of that filter return more than one row.

I know how to do this in ADO.NET but I need specific code examples on how to get the dataset attached to the XtraGrid.

Thanks!!!
 
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
private void view_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e)
        {
            if (view.FocusedColumn.Name == "Product" || view.FocusedColumn.Name == "SubProd" || view.FocusedColumn.Name == "Type")
            {
                //Data filter code here
                if (false == false) 
                    e.Valid = false;
            }
        }

Answer : What is the best way to walk through a DataSource of a DevExpress XtraGrid to see if there are any duplicate values in the rows?

if you just want to go throught the datasource and you know that it is a datatable. im assuming you meant datatable.


DataTable dt = yourGridControl.DataSource as DataTable;
//either way cast the GridControls DataSource as the type that you assigned to it and then you can look at it locally.
Random Solutions  
 
programming4us programming4us