Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
Checking for duplicate rows before adding a new row.
posted

I am working with a UltraWinGrid which has an attached UltraDataSource. Im using vb.NET to develop my application. My problem is that I cannot find an easy way to check if a row exists within the rows collection of either the WinGrid or the DataSource.

To add a new row to the datasource im using the following code:-

Dim o = New Object()  {False, emailImage, status}
dsDocuments.Rows.Add(o)

This will add the row to the datasource and the wingrid fine, however some of the rows which I will add contain duplicate data and I need a way to detect if the data already exists so I can cancel the row being added. I have tried using the following to no avail:-

If  Not (dsDocuments.Rows.Contains(o)) Then
      dsDocuments.Rows.Add(o)
End If

However the compiler shows an error as the array cannot be converted to an gridrow or a datasourcerow. I have tried using the events raised (rowadding & rowadded) and still cannot find a solution.

Is there an easy way to check if a duplicate row exists without looping through each row?

 

Thanks

Sean 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Sean,

    You will have to loop through the rows and compare the values of each field. You cannot use Contains, because Contains is probably expecting you to pass in a DataRow - and even if you had a DataRow, it would just do a reference comparison, which would never be true.

Children